* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --bg-gradient-start: #1e1b4b;
    --bg-gradient-end: #312e81;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-hover: rgba(255, 255, 255, 0.15);
}

body {
    font-family: 'Bricolage Grotesque', sans-serif;
    /* background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%); */
    background-color: rgb(28,28,28);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Page Management */
.page {
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease;
}

.page.hidden {
    display: none;
    opacity: 0;
}

/* Settings Page */
.settings-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 40px 20px;
}

.settings-header {
    text-align: center;
    margin-bottom: 40px;
}

.settings-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
}

.settings-header p {
    color: var(--text-secondary);
    font-size: 1.1em;
}

.settings-form {
    /* background: var(--card-bg); */
    background: rgb(0 0 0 / 60%);
    /* backdrop-filter: blur(20px); */
    /* border-radius: 20px; */
    padding: 30px;
    border: 1px solid #434343;
    /* box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); */
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 1em;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    font-size: 1em;
    font-family: 'Rubik', sans-serif;
    transition: all 0.3s ease;
    cursor: pointer;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.4);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    background-size: 12px;
    padding-right: 45px;
}

.form-group select option {
    background: #1e1b4b;
    color: white;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.85em;
}

.form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    vertical-align: middle;
    cursor: pointer;
}

/* Hide camera selection on desktop (only show on mobile/tablet) */
.camera-selection-group {
    display: none;
}

@media (max-width: 1024px) {
    .camera-selection-group {
        display: block;
    }
}

.settings-footer {
    text-align: center;
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Rubik', sans-serif;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(84, 84, 84, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Styles Page */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    /* background: rgba(0, 0, 0, 0.3); */
    backdrop-filter: blur(20px);
    border-bottom: 2px solid #3d73ff;
}

.header h1 {
    font-size: 1.8em;
    font-weight: 700;
    color: #3c73ff;
}

.header-icons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-icon {
    background: rgb(0 0 0 / 0%);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #3d73ff;
}

.header-icon:hover {
    background: rgb(0 0 0 / 20%);
    transform: rotate(90deg);
}

.settings-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-icon:hover {
    background: rgba(84, 84, 84, 0.4);
    transform: rotate(90deg);
}

.instructions {
    text-align: center;
    padding: 30px 20px;
}

.instructions p {
    font-size: 1.2em;
    /* color: var(--text-secondary); */
    color: #3d73ff;
}

.styles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    /* padding: 0 20px 40px; */
    max-width: 1000px;
    margin: 0 auto;
}

/* Category header spans full width */
.category-header {
    grid-column: 1 / -1;
    padding: 20px 10px 10px;
    margin-top: 20px;
    /* background set via inline style with category color */
    border-radius: 8px;
}

.category-header h2 {
    font-size: 1.5em;
    font-weight: 600;
    /* color and border-bottom set via inline style with category color */
    border-bottom-width: 2px;
    border-bottom-style: solid;
    padding-bottom: 10px;
}

.style-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    /* border-radius: 20px; */
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    aspect-ratio: 1 / 1;
}

.style-card:hover {
    transform: translateY(-8px);
    background: var(--card-hover);
    box-shadow: 0 15px 40px rgba(84, 84, 84, 0.4);
}

.style-card:active {
    transform: translateY(-4px);
}

.style-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.style-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    transition: all 0.3s ease;
}

.style-card:hover .style-card-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.style-card-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.95;
}

.style-card-icon i {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.style-card-title {
    font-size: 1.1em;
    text-align: center;
    font-weight: 600;
    margin-bottom: 4px;
}

.style-card-index {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.style-card-random {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    min-height: 160px;
}

.style-card-random img {
    object-fit: cover;
    height: 100%;
}

.style-card-random .style-card-overlay {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.85) 100%);
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
}

.style-card-random .style-card-title {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 8px;
}

.style-card-random .style-card-index {
    font-size: 1.1em;
}

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Camera Page */
.camera-container {
    position: absolute;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    background: #000;
    overflow: hidden;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover to fill screen, matches what will be captured */
}

/* Visual guide overlay showing capture area (4:3 aspect ratio) */
.camera-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* On 16:9 screen in landscape, show 4:3 guide with visible margins */
    width: min(100vw, calc(100vh * 1.333)); /* 4:3 aspect: width = height * 1.333 */
    height: min(calc(100vw * 0.75), 100vh);  /* height = width * 0.75 */
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 
        0 0 0 2000px rgba(0, 0, 0, 0.3),  /* Darken outside area */
        inset 0 0 30px rgba(0, 0, 0, 0.2); /* Inner shadow for depth */
    pointer-events: none;
    box-sizing: border-box;
    border-radius: 8px;
}

/* Corner markers for better visibility */
.camera-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(100vw, calc(100vh * 1.333));
    height: min(calc(100vw * 0.75), 100vh);
    pointer-events: none;
    background: 
        /* Top-left corner */
        linear-gradient(white, white) 0 0 / 40px 4px no-repeat,
        linear-gradient(white, white) 0 0 / 4px 40px no-repeat,
        /* Top-right corner */
        linear-gradient(white, white) 100% 0 / 40px 4px no-repeat,
        linear-gradient(white, white) 100% 0 / 4px 40px no-repeat,
        /* Bottom-left corner */
        linear-gradient(white, white) 0 100% / 40px 4px no-repeat,
        linear-gradient(white, white) 0 100% / 4px 40px no-repeat,
        /* Bottom-right corner */
        linear-gradient(white, white) 100% 100% / 40px 4px no-repeat,
        linear-gradient(white, white) 100% 100% / 4px 40px no-repeat;
    opacity: 0.7;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, transparent 20%, transparent 80%, rgba(0, 0, 0, 0.5) 100%);
}

.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

.btn-back {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Rubik', sans-serif;
}

.btn-back:hover {
    background: rgba(84, 84, 84, 0.4);
    transform: translateX(-4px);
}

.style-name {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: 600;
}

.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10em;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 40px rgba(99, 102, 241, 0.8);
    animation: countdown-pulse 1s ease-in-out;
    display: none;
}

@keyframes countdown-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

.camera-controls {
    display: flex;
    justify-content: center;
    padding: 30px;
}

.btn-capture {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: 4px solid white;
    border-radius: 50%;
    width: 90px;
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.5);
    font-family: 'Rubik', sans-serif;
}

.btn-capture:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 50px rgba(99, 102, 241, 0.7);
}

.btn-capture:active {
    transform: scale(0.95);
}

.camera-icon {
    font-size: 2em;
}

.btn-capture span:last-child {
    font-size: 0.7em;
    font-weight: 600;
    margin-top: 4px;
}

.camera-info {
    text-align: center;
    padding: 0 20px 40px;
}

.camera-info p {
    font-size: 1.1em;
    font-weight: 500;
    margin-bottom: 4px;
}

.camera-info small {
    color: var(--text-secondary);
}

/* Upload Page */
.upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
}

.preview-image {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 4 / 3;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-image {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 4 / 3;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 40px;
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.6);
    animation: result-reveal 0.5s ease-out;
    display: none; /* Hidden by default */
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes result-reveal {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.upload-status {
    text-align: center;
    max-width: 500px;
}

.status-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}

.status-icon.success {
    color: var(--success-color);
    font-size: 4em;
}

.status-icon.error {
    color: var(--error-color);
    font-size: 4em;
}

#status-title {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 10px;
}

#status-message {
    color: var(--text-secondary);
    font-size: 1.1em;
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.4em;
    }
    
    .styles-grid {
        gap: 15px;
    }
    
    .category-header h2 {
        font-size: 1.2em;
    }
    
    .category-header {
        padding: 15px 10px 10px;
        margin-top: 15px;
    }
    
    .countdown {
        font-size: 6em;
    }
    
    .btn-capture {
        width: 80px;
        height: 80px;
    }

    .style-card-title {
        font-size: .8em;
    }
    .style-card-index {
        font-size: 0.6em;
    }
    .style-card-icon {
        font-size: 1em; 
        margin-bottom: 5px;
    }
}

/* Landscape mode enforcement */
@media (orientation: portrait) {
        .camera-container::before {
        content: '🔄 Please rotate your device to landscape mode';
        /* position: absolute; */
        /* top: 50%; */
        /* left: 50%; */
        /* bottom: 50%; */
        /* transform: translate(-50%, -50%); */
        background: rgba(0, 0, 0, 1);
        padding: 30px;
        /* padding-top: 50px; */
        border-radius: 20px;
        text-align: center;
        font-size: 1.2em;
        font-weight: 600;
        z-index: 1000;
        max-width: 80%;
        box-sizing: border-box;
        display: flex
;
        justify-content: center;
        align-items: center;
    }
}

/* ========================================
   🖨️ INSTAX PRINTER SETTINGS STYLES
   ======================================== */

.printer-settings-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.printer-settings-section .section-header {
    margin-bottom: 20px;
}

.printer-settings-section .section-header h3 {
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 5px;
}

.printer-settings-section .section-header small {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Printer Status Display */
.printer-status {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.95em;
    white-space: nowrap;
}

.status-badge.connected {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge i {
    font-size: 0.7em;
}

.printer-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.printer-info .separator {
    color: rgba(255, 255, 255, 0.3);
}

/* Printer List Dropdown */
#printer-select {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1em;
    outline: none;
    transition: all 0.3s ease;
}

#printer-select:focus {
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.4);
}

#printer-select option {
    background: #1a1a1a;
    padding: 10px;
}

/* Printer Control Buttons */
.printer-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.btn-secondary {
    width: 100%;
    padding: 14px 24px;
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    flex: 1;
    padding: 14px 24px;
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 2px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-success:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.5);
    transform: translateY(-2px);
}

.btn-success:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-danger {
    flex: 1;
    padding: 14px 24px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
    transform: translateY(-2px);
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Printer Note */
.printer-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-top: 15px;
}

.printer-note i {
    color: var(--primary-color);
    margin-top: 2px;
}

.printer-note small {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Printer Unavailable State */
.printer-unavailable {
    text-align: center;
    padding: 40px 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 2px dashed rgba(239, 68, 68, 0.3);
    border-radius: 12px;
}

.printer-unavailable i {
    font-size: 3em;
    color: #ef4444;
    margin-bottom: 15px;
}

.printer-unavailable p {
    font-weight: 600;
    margin-bottom: 5px;
}

.printer-unavailable small {
    color: var(--text-secondary);
}

/* Toast Notification System */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1em;
    font-weight: 500;
    z-index: 10000;
    min-width: 300px;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: bottom 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    bottom: 30px;
}

.toast i {
    font-size: 1.3em;
}

.toast-info {
    border-color: rgba(99, 102, 241, 0.5);
}

.toast-info i {
    color: #6366f1;
}

.toast-success {
    border-color: rgba(34, 197, 94, 0.5);
}

.toast-success i {
    color: #22c55e;
}

.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
}

.toast-error i {
    color: #ef4444;
}

.toast-warning {
    border-color: rgba(245, 158, 11, 0.5);
}

.toast-warning i {
    color: #f59e0b;
}

