:root {
    /* Brand/Constant Colors */
    --primary-color: #ff6d00;
    --secondary-color: #34495e;
    --accent-color: #2563eb;
    --error: #dc2626;
    --success: #10b981;
    --white: #ffffff;
    
    /* Light Theme (Default) */
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --header-bg: #1e293b;
    --header-text: #ffffff;
    --header-border: rgba(0, 0, 0, 0.1);
    --panel-bg: #f1f5f9;
    --table-header-bg: #f8f9fa;
    --table-border: #eeeeee;
    --input-bg: #ffffff;
    --input-border: #dddddd;
    --input-text: #1e293b;
    --footer-bg: #004085;
}

[data-theme="dark"] {
    /* Dark Theme Override */
    --bg-color: #0b0f19;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --card-border: rgba(255, 255, 255, 0.08);
    --header-bg: #1e293b;
    --header-text: #ffffff;
    --header-border: rgba(255, 255, 255, 0.1);
    --panel-bg: #1e293b;
    --table-header-bg: rgba(255, 255, 255, 0.03);
    --table-border: rgba(255, 255, 255, 0.06);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.15);
    --input-text: #ffffff;
    --footer-bg: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

/* Auth Pages */
.auth-page {
    background: linear-gradient(rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.8)), url('../../fondo/fondo.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-container {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2.5rem 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    text-align: center;
    color: #f1f5f9;
}

.auth-container h1 {
    margin-bottom: 1.5rem;
    color: #ff6d00;
    font-size: 1.8rem;
    font-weight: 700;
}

.auth-container .error {
    color: #f87171;
    font-weight: 600;
}

/* Premium dark inputs for auth container */
.auth-container .form-group input, 
.auth-container .form-group select, 
.auth-container .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, background-color 0.2s;
}

.auth-container .form-group input:focus, 
.auth-container .form-group select:focus, 
.auth-container .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.auth-container .form-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.auth-container .form-group select option {
    background-color: #1e293b;
    color: #ffffff;
}




.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/*.btn {
    display: inline-block;
    background: var(--accent-color);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.3s ease;
    width: 100%;
}

.btn:hover {
    background: blue;
}*/
.btn {
    display: inline-block;
    background: var(--primary-color);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
}

.btn-guest {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #0d9488 0%, #047857 100%);
    color: #ffffff !important;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
    transition: all 0.2s ease;
    cursor: pointer;
    text-align: center;
}

.btn-guest:hover {
    background: linear-gradient(135deg, #0f766e 0%, #065f46 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(13, 148, 136, 0.5);
}

.btn:hover {
    background: #e05300;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-reader {
    background: #0ea5e9;
}
.btn-reader:hover {
    background: #0284c7;
}
.btn-admin-user {
    background: #8b5cf6;
}
.btn-admin-user:hover {
    background: #7c3aed;
}

.error {
    color: var(--error);
    margin-bottom: 1rem;
    font-weight: bold;
}

.success {
    color: var(--success);
    margin-bottom: 1rem;
}

/* Main Layout */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    max-width: 100%;
    background: var(--header-bg);
    color: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--header-border, transparent);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

header.header-hidden {
    transform: translateY(-100%);
}

header h1 {
    font-size: 1.5rem;
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

nav a {
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease, opacity 0.2s ease;
}

nav a:hover {
    color: var(--white);
}

.boton-logout {
    background-color: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 6px;
    display: inline-block;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.boton-logout:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
}

.container {
    min-height: 100dvh;
    max-width: 1200px;
    margin: 6rem auto 2rem auto;
    padding: 0 1rem;
}

/* Book Grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.book-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-5px);
}

.book-cover-link {
    display: block;
    overflow: hidden;
    height: 280px;
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #eee;
    transition: transform 0.3s ease;
}

.book-cover-link:hover .book-cover {
    transform: scale(1.05);
}

.book-info {
    text-align: center;
    padding: 1rem;
    flex-grow: 1;
}

.book-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.book-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.book-actions {
    padding: 1rem;
    border-top: 1px solid var(--table-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-read {
    background: #2563eb;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.65rem 1rem;
    font-size: 0.92rem;
    border-radius: 6px;
    font-weight: 600;
}

.btn-read:hover {
    background: #1d4ed8;
    color: #ffffff;
}

.btn-download {
    background: #0d9488;
    color: #ffffff !important;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(13, 148, 136, 0.4);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-download:hover {
    background: #0f766e;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.3);
}

.btn-download.btn-download-locked {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706 !important;
    border: 1px dashed rgba(245, 158, 11, 0.5);
}

.btn-download.btn-download-locked:hover {
    background: rgba(245, 158, 11, 0.22);
    border-color: #d97706;
    color: #b45309 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .btn-download.btn-download-locked {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24 !important;
    border-color: rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .btn-download.btn-download-locked:hover {
    background: rgba(245, 158, 11, 0.25);
    color: #fef08a !important;
}

/* Search Bar */
.search-container {
    margin-bottom: 2rem;
}

.search-container input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--input-text);
    border-radius: 25px;
    font-size: 1rem;
}

/* Admin Panel */
.admin-actions {
    margin-bottom: 2rem;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

th,
td {
    padding: 1rem;
    border-bottom: 1px solid var(--table-border);
    text-align: left;
}

th {
    background: var(--table-header-bg);
    color: var(--text-color);
}











.main-footer {
    border-top: 10px solid var(--primary-color);
    background: var(--footer-bg);
    color: var(--white);
    padding-inline: 5px;
    padding-block: 30px;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: white;
    font-family: Arial, sans-serif;
    transition: background-color 0.3s ease;
}

.footer-bottom {
    text-align: center;
    font-size: 14px;
}




/* Responsive Adjustments */
@media (max-width: 720px) {
    header {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    header h1 {
        font-size: 1.3rem;
        margin: 0.5rem 0;
    }

    nav {
        margin-top: 1rem;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem;
        width: 100%;
    }

    nav span {
        width: 100%;
        text-align: center;
        margin-bottom: 0.2rem;
        font-size: 0.9rem;
    }

    .container {
        margin: 1rem auto;
        padding: 0 0.75rem;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.25rem;
    }

    .book-cover-link {
        height: 240px;
    }

    body {
        display: flex;
        flex-direction: column;
    }

    .auth-container {
        padding: 1.5rem 1.25rem;
        width: 95%;
        max-width: 100%;
        margin: 1rem auto;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: 6px;
    }
    
    .table-container table {
        min-width: 600px;
    }
    
    /* Make buttons full-width in admin quick actions on mobile */
    .admin-quick-actions div a.btn {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    /* Stack form actions vertically on very small screens */
    .auth-container form div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .auth-container form div[style*="display: flex"] button,
    .auth-container form div[style*="display: flex"] a {
        width: 100% !important;
        margin: 0 !important;
    }
    
    .auth-container h1 {
        font-size: 1.5rem;
    }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
}

[data-theme="dark"] .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Guest Download Modal */
.guest-download-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: modalBackdropFadeIn 0.2s ease;
}

@keyframes modalBackdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.guest-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(5px);
}

.guest-modal-dialog {
    position: relative;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 5001;
    overflow: hidden;
    animation: modalContentPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalContentPop {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.guest-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    background: rgba(13, 148, 136, 0.06);
}

.guest-modal-badge-icon {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.15);
    border-radius: 10px;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.guest-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-color);
}

.guest-modal-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.guest-modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.guest-modal-close-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.1);
}

.guest-modal-body {
    padding: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.55;
}

.guest-modal-perks {
    margin-top: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--panel-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

.guest-perk-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.88rem;
}

.guest-perk-item p {
    margin: 2px 0 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.guest-perk-icon {
    font-size: 1.1rem;
    line-height: 1.2;
}

.guest-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.02);
}

.btn-modal-primary {
    background: linear-gradient(135deg, #0d9488 0%, #047857 100%);
    color: #ffffff !important;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
    transition: all 0.2s ease;
}

.btn-modal-primary:hover {
    background: linear-gradient(135deg, #0f766e 0%, #065f46 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.5);
}

.btn-modal-secondary {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-modal-secondary:hover {
    background: var(--panel-bg);
    color: var(--text-color);
}