/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --bg-dark: #0f0f23;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --success: #10b981;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 50%);
    animation: gradientShift 15s ease-in-out infinite;
    z-index: -1;
}

@keyframes gradientShift {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Setup Screen */
.setup-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.setup-container {
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    margin-bottom: 16px;
}

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 24px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-field {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
}

.btn-icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}

.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.15);
}

.hint {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Album Screen */
.album-screen {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin: 12px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h2 {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.image-counter {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.new-badge {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--success), #059669);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
    min-height: 0;
}

/* Viewer Section */
.viewer-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.current-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.current-image-container img {
    max-width: calc(100% - 100px);
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    animation: imageIn 0.4s ease-out;
}

@keyframes imageIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Print Button - Top Right Corner */
.print-btn {
    position: absolute;
    top: 50px;
    right: 0px;
    width: 150px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.print-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

/* Navigation Buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: white;
    font-size: 28px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.nav-btn:hover {
    background: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

.nav-prev {
    left: 12px;
}

.nav-next {
    right: 12px;
}

.image-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* Thumbnails - List Style */
.thumbnails-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}

.thumbnails-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.thumbnail-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 8px;
}

.thumbnail-list::-webkit-scrollbar {
    width: 6px;
}

.thumbnail-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.thumbnail-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.thumbnail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
}

.thumbnail-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.thumbnail-item.active {
    border-color: var(--secondary);
    background: rgba(236, 72, 153, 0.1);
}

.thumbnail-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.thumbnail-item .filename {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thumbnail-item.new::before {
    content: 'NEW';
    padding: 2px 6px;
    background: var(--success);
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 4px;
    flex-shrink: 0;
}

/* QR Section */
.qr-section {
    padding: 16px;
    flex-shrink: 0;
}

.qr-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.qr-input-group {
    margin-bottom: 12px;
}

.qr-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 30px;
}

.qr-container canvas,
.qr-container img {
    border-radius: 12px;
    padding: 20px;
    background-color: white;
}

.qr-placeholder {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Print Styles ===== */
.print-area {
    display: none;
}

@media print {
    @page {
        margin: 0;
        size: auto;
    }

    body * {
        visibility: hidden;
    }

    .print-area,
    .print-area * {
        visibility: visible;
    }

    .print-area {
        display: flex !important;
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        align-items: center;
        justify-content: center;
        background: white;
    }

    .print-area img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }

    .sidebar {
        flex-direction: row;
        height: 200px;
    }

    .thumbnails-section,
    .qr-section {
        flex: 1;
    }
}

@media (max-width: 600px) {
    .header {
        margin: 8px;
        padding: 10px 14px;
    }

    .main-content {
        padding: 8px;
        gap: 8px;
    }

    .sidebar {
        flex-direction: column;
        height: auto;
    }

    .thumbnail-list {
        max-height: 150px;
    }
}