/* Variables de Estilo CSS3 */
:root {
    --primary-color: #1a365d;
    --primary-light: #2b6cb0;
    --accent-color: #319795;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --danger-color: #e53e3e;
    --success-color: #38a169;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header & Navegación Flexbox */
.navbar {
    background-color: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
}

.logo span {
    font-size: 1.4rem;
    font-weight: bold;
}

nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: #e2e8f0;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: background-color 0.2s;
}

.nav-btn:hover, .nav-btn.active {
    background-color: var(--primary-light);
    color: white;
}

/* Layout Principal */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Inputs y Botones */
.input-search, input[type="text"], input[type="password"], input[type="number"], input[type="date"], textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.input-search {
    max-width: 350px;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.9; }
.btn-primary { background-color: var(--primary-light); color: white; }
.btn-success { background-color: var(--success-color); color: white; }
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-secondary { background-color: var(--text-muted); color: white; }

/* Grid del Catálogo */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.book-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.book-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.book-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}
.badge-available { background-color: #c6f6d5; color: #22543d; }
.badge-unavailable { background-color: #fed7d7; color: #742a2a; }

/* Tablas */
.table-wrapper {
    overflow-x: auto;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.data-table th {
    background-color: #edf2f7;
    color: var(--primary-color);
}

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.login-card {
    max-width: 400px;
    margin: 3rem auto;
}

/* Modales */
.hidden { display: none !important; }

.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 1rem; right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.form-group { margin-bottom: 0.8rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.2rem; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Dashboard Estadísticas */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

@media (max-width: 768px) {
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    .navbar { flex-direction: column; gap: 1rem; }
}