:root {
    /* Color System - Light Premium (Sobrio y Claro) */
    --bg-body: #f8f9fa;          /* Fondo claro grisáceo/crema */
    --bg-sidebar: #1d3768;       /* Sidebar blanca */
    --bg-card: #ffffff;          /* Tarjetas blancas */
    --bg-input: #fdfdfd;         /* Inputs levemente grises */
    
    --text-primary: #2c3e50;     /* Texto principal azul oscuro/pizarra */
    --text-secondary: #596775;   /* Texto secundario */
    --text-muted: #4a5568;       /* Texto tenue */
    
    --brand-primary: #1d3768;    /* Azul Masónico Clásico */
    --brand-accent: #b8973e;     /* Oro antiguo elegante */
    --brand-danger: #c0392b;     /* Rojo alerta */
    --brand-success: #27ae60;    /* Verde éxito */
    
    --border-color: #e2e8f0;     /* Bordes suaves */
    
    /* Metrics */
    --radius: 8px;
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.08); /* Sombra más suave para modo claro */
    --font-heading: 'Cinzel', 'Trajan Pro', 'Georgia', serif; /* Masonic/Classic feel */
    --font-body: 'Roboto', 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg-body);
    /* Retiramos la imagen pesada global y ponemos un fondo claro y sobrio */
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: flex;
    min-height: 100vh;
}

/* Fondo Masónico (Pavimento de Mosaico sutil) solo para el inicio de sesión */
body.login-page {
    background-color: #1d3768;
    background-image: 
      linear-gradient(45deg, #152c56 25%, transparent 25%, transparent 75%, #152c56 75%, #152c56),
      linear-gradient(45deg, #152c56 25%, transparent 25%, transparent 75%, #152c56 75%, #152c56);
    background-size: 80px 80px;
    background-position: 0 0, 40px 40px;
    position: relative;
}

/* Overlay radial para darle elegancia y enfocar el centro en el login */
body.login-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle, transparent 20%, rgba(29, 55, 104, 0.9) 100%);
    z-index: 0;
}

.login-card {
    position: relative;
    z-index: 1; /* Para que quede sobre el mosaico */
}

/* Typography */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-top: 0;
    font-weight: 700;
}

h1 { font-size: 2rem; color: var(--brand-accent); }
h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; margin-bottom: 1.5rem; }
a { color: var(--brand-primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--brand-accent); }

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    height: 100vh;
    position: fixed;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
    text-align: center;
}

.sidebar h3 {
    color: var(--brand-accent);
    font-size: 1.4rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.sidebar nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar a {
    padding: 12px 20px;
    color: #e2e8f0;
    display: block;
    border-left: 3px solid transparent;
}

.sidebar a:hover, .sidebar a.active {
    background-color: rgba(0, 0, 0, 0.05);
    color: #ffffff;
    border-left-color: var(--brand-accent);
}

.sidebar-section-title {
    padding: 15px 20px 5px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: #e2e8f0;
}

/* Main Content */
.content {
    margin-left: 260px;
    padding: 30px;
    flex: 1;
    width: 100%;
}

/* Cards */
.card, .container.card-style, .login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 25px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Forms */
.form-group { margin-bottom: 1.5rem; }

input[type='text'], 
input[type='password'], 
input[type='email'], 
input[type='number'],
input[type='date'],
input[type='file'],
select, 
textarea {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 5px rgba(255, 179, 0, 0.2);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s, transform 0.1s;
    font-size: 0.95rem;
    color: white;
    background-color: var(--brand-primary);
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-primary { background-color: var(--brand-primary); }
.btn-secondary { background-color: #e2e8f0; color: var(--text-primary); border: 1px solid #cbd5e1; }
.btn-accent { background-color: var(--brand-accent); color: #fff; }
.btn-success { background-color: var(--brand-success); }
.btn-danger { background-color: var(--brand-danger); }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    color: var(--text-primary);
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
}

tr:hover { background-color: rgba(0, 0, 0, 0.02); }

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    background: #444;
}

/* Utilities */
.text-gold { color: var(--brand-accent); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.active { transform: translateX(0); }
    .content { margin-left: 0; padding: 20px; }
    .sidebar-overlay {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5); z-index: 90; display: none;
    }
    .sidebar-overlay.active { display: block; }
    .mobile-nav-toggle {
        display: block; position: fixed; top: 15px; left: 15px; z-index: 110;
        background: var(--bg-card); border: 1px solid var(--border-color);
        color: var(--text-primary); padding: 8px 12px; border-radius: 4px;
    }
}
@media (min-width: 769px) {
    .mobile-nav-toggle, .sidebar-overlay { display: none !important; }
}

/* Login */
.login-card {
    max-width: 400px;
    width: 90%;
    margin: auto;
    border-top: 4px solid var(--brand-accent);
    padding: 40px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    background: #ffffff;
}
.logo-login { max-width: 120px; display: block; margin: 0 auto 20px; }
.login-footer { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1rem 0;
}

th {
    background-color: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 80%;
        max-width: 320px;
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .content {
        margin-left: 0;
        padding: 20px;
    }
    

/* Library Specific Styles */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.library-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--brand-accent);
    border-bottom-color: var(--brand-accent);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.list-container .card {
    flex-direction: row;
    height: auto;
    align-items: center;
    padding: 1rem;
}

.list-container .card-cover {
    width: 60px;
    height: 90px;
    flex-shrink: 0;
    margin-right: 1.5rem;
}

.list-container .card-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.list-container .card-actions {
    display: flex;
    flex-direction: row; /* Horizontal actions in list view */
    gap: 0.5rem;
}

.card-cover {
    height: 280px; /* Taller covers generally better */
    background-color: var(--bg-input);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

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

.card-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: var(--brand-accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    backdrop-filter: blur(2px);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-sizing: border-box; /* Fix for 100% width causing overflow */
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* Login Page Specifics */
body.login-page {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    text-align: center;
    border: 1px solid var(--border-color);
}

.logo-login {
    height: 80px;
    margin-bottom: 1.5rem;
    opacity: 1;
    border-radius: 50%;
    object-fit: cover;
    width: 80px;
}

.login-card h2 {
    color: var(--brand-accent);
    border-bottom: none;
    margin-bottom: 0.5rem;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Status Helpers */
.badge-success { background-color: var(--brand-success); color: white; }
.badge-warning { background-color: var(--brand-accent); color: black; }
.badge-danger { background-color: var(--brand-danger); color: white; }
.badge-info { background-color: var(--brand-primary); color: white; }

.text-success { color: var(--brand-success) !important; }
.text-warning { color: var(--brand-accent) !important; }
.text-danger { color: var(--brand-danger) !important; }
.text-info { color: var(--brand-primary) !important; }

/* Dashboard Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

table th {
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    padding: 0.75rem;
    text-align: left;
}

table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

table tr:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.logo-login { width: 120px !important; height: 120px !important; object-fit: cover; border-radius: 50%; border: 3px solid var(--brand-accent); box-shadow: 0 4px 10px rgba(0,0,0,0.1); margin: 0 auto 20px; display: block; opacity: 1 !important; }
.logo-login { width: 120px !important; height: 120px !important; object-fit: cover; border-radius: 50%; border: 3px solid var(--brand-accent); box-shadow: 0 4px 10px rgba(0,0,0,0.1); margin: 0 auto 20px; display: block; opacity: 1 !important; }
.form-control { width: 100%; padding: 12px; background-color: var(--bg-input); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-family: inherit; font-size: 1rem; box-sizing: border-box; transition: all 0.2s; }.form-control:focus { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 3px rgba(184, 151, 62, 0.2); }
