/* CSS Variables */
:root {
    /* Typography */
    --font-heading: 'EB Garamond', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Colors */
    --primary-color: #1a1a1a;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --shelf-white: #ffffff;
    --shelf-shadow: #f1f5f9;
    --shelf-depth: #e2e8f0;
    --text-dark: #1a1a1a;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --background-main: #ffffff;
    --background-subtle: #f8fafc;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.1), 0 5px 10px rgba(0,0,0,0.04);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    min-height: 100vh;
    background: var(--background-main);
    color: var(--text-dark);
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
}

.container-narrow {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* ==================== AUTH PAGES ==================== */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo img {
    max-width: 180px;
    height: auto;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 500;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 32px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: var(--font-body);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--background-subtle);
    color: var(--text-dark);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.error {
    border-color: var(--error-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--font-body);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    width: 100%;
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #333;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-secondary {
    background: var(--background-subtle);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

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

/* Links */
.auth-link {
    display: block;
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.auth-link a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.message-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.message-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* 2FA Setup */
.qr-container {
    text-align: center;
    padding: 24px;
    background: var(--background-subtle);
    border-radius: 12px;
    margin: 24px 0;
}

.qr-code {
    display: inline-block;
    padding: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.qr-code img,
.qr-code canvas {
    display: block;
}

.secret-key {
    margin-top: 16px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: var(--text-dark);
    word-break: break-all;
}

.otp-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 24px 0;
}

.otp-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--background-subtle);
    transition: all 0.2s ease;
}

.otp-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: white;
}

/* ==================== ADMIN DASHBOARD ==================== */

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.admin-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 500;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.user-table th,
.user-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.user-table th {
    background: var(--background-subtle);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-table tr:last-child td {
    border-bottom: none;
}

.user-table tr:hover td {
    background: var(--background-subtle);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-approved {
    background: #d1fae5;
    color: #065f46;
}

.status-active {
    background: #dbeafe;
    color: #1e40af;
}

.status-disabled {
    background: #f1f5f9;
    color: #64748b;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== MAIN PAGE (BOOKSHELF) ==================== */

.header {
    text-align: center;
    margin-bottom: 50px;
    animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-container {
    margin-bottom: 20px;
}

.logo {
    max-width: 200px;
    height: auto;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.title {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.subtitle {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--text-light);
    font-weight: 400;
}

/* User Info Bar */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--background-subtle);
    border-radius: 12px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-name {
    font-weight: 500;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-light);
}

.session-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.timer-icon {
    font-size: 1.2rem;
}

/* Bookshelf */
.bookshelf {
    background: white;
    border-radius: 20px;
    padding: 30px 50px 40px;
    position: relative;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Shelf Sides */
.shelf-side {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 25px;
    background: linear-gradient(90deg, #f1f5f9 0%, #ffffff 50%, #f1f5f9 100%);
}

.shelf-side.left {
    left: 0;
    border-radius: 20px 0 0 20px;
    background: linear-gradient(90deg, #e2e8f0 0%, #f8fafc 100%);
}

.shelf-side.right {
    right: 0;
    border-radius: 0 20px 20px 0;
    background: linear-gradient(90deg, #f8fafc 0%, #e2e8f0 100%);
}

/* Individual Shelf */
.shelf {
    position: relative;
    margin-bottom: 20px;
    padding-bottom: 25px;
}

.shelf:last-of-type {
    margin-bottom: 0;
}

.shelf-content {
    display: flex;
    gap: 25px;
    padding: 20px 10px;
    min-height: 160px;
    align-items: flex-end;
}

/* Shelf Board (3D Effect) */
.shelf-board {
    position: relative;
    height: 20px;
}

.shelf-front {
    position: absolute;
    bottom: 0;
    left: -25px;
    right: -25px;
    height: 8px;
    background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
    border-radius: 0 0 4px 4px;
}

.shelf-bottom {
    position: absolute;
    bottom: 8px;
    left: -25px;
    right: -25px;
    height: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    box-shadow: 
        0 2px 8px rgba(0,0,0,0.08),
        inset 0 -2px 4px rgba(0,0,0,0.03);
}

/* App Items (Books) */
.app-item {
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: bookAppear 0.5s ease-out backwards;
}

.app-item:nth-child(1) { animation-delay: 0.3s; }
.app-item:nth-child(2) { animation-delay: 0.4s; }
.app-item:nth-child(3) { animation-delay: 0.5s; }
.app-item:nth-child(4) { animation-delay: 0.6s; }

@keyframes bookAppear {
    from {
        opacity: 0;
        transform: translateY(20px) rotateY(-20deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateY(0);
    }
}

.app-item:hover {
    transform: translateY(-10px) scale(1.05);
}

.app-item:hover .app-book {
    box-shadow: 
        0 15px 30px rgba(0,0,0,0.12),
        0 5px 15px rgba(0,0,0,0.08);
}

.app-book {
    width: 100px;
    height: 130px;
    position: relative;
    display: flex;
    transition: all 0.3s ease;
    box-shadow: 
        0 5px 15px rgba(0,0,0,0.1),
        0 2px 5px rgba(0,0,0,0.05);
    border-radius: 4px 8px 8px 4px;
    overflow: hidden;
}

/* Book Spine */
.book-spine {
    width: 12px;
    background: linear-gradient(180deg, #1a1a1a 0%, #333 100%);
    border-radius: 4px 0 0 4px;
    box-shadow: inset -2px 0 4px rgba(0,0,0,0.2);
}

/* Book Cover */
.book-cover {
    flex: 1;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 0 8px 8px 0;
    border: 1px solid #e2e8f0;
    border-left: none;
}

.app-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    transition: transform 0.3s ease;
}

.app-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.app-item:hover .app-icon {
    transform: scale(1.15);
}

.app-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    line-height: 1.2;
}

/* Different Book Colors */
.app-item:nth-child(1) .book-spine {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.app-item:nth-child(2) .book-spine {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.app-item:nth-child(3) .book-spine {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
}

.app-item:nth-child(4) .book-spine {
    background: linear-gradient(180deg, #a855f7 0%, #9333ea 100%);
}

.app-item:nth-child(5) .book-spine {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}

.app-item:nth-child(6) .book-spine {
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
}

/* Add New App Style */
.add-new .book-cover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px dashed #cbd5e1;
}

.add-new .book-spine {
    background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
}

.add-new .app-icon {
    color: var(--text-light);
}

.add-new .app-name {
    color: var(--text-light);
}

.add-new:hover .book-cover {
    border-color: var(--accent-color);
}

.add-new:hover .app-icon {
    color: var(--accent-color);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }

    .title {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .bookshelf {
        padding: 20px 30px 30px;
    }

    .shelf-content {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }

    .app-book {
        width: 85px;
        height: 110px;
    }

    .app-icon {
        font-size: 2rem;
    }

    .app-name {
        font-size: 0.65rem;
    }

    .shelf-side {
        width: 15px;
    }

    .shelf-front,
    .shelf-bottom {
        left: -15px;
        right: -15px;
    }

    .auth-card {
        padding: 32px 24px;
    }

    .user-bar {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .user-table {
        display: block;
        overflow-x: auto;
    }

    .action-buttons {
        flex-direction: column;
    }

    .admin-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }

    .logo {
        max-width: 150px;
    }

    .bookshelf {
        padding: 15px 20px 25px;
        border-radius: 15px;
    }

    .app-book {
        width: 75px;
        height: 100px;
    }

    .book-spine {
        width: 8px;
    }

    .app-icon {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }

    .app-name {
        font-size: 0.6rem;
    }

    .otp-input {
        width: 40px;
        height: 48px;
        font-size: 1.25rem;
    }
}

/* ==================== UTILITIES ==================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 24px;
}

.mb-4 {
    margin-bottom: 24px;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Fade animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
