:root {
    --primary: #2d6fb6;
    --primary-light: #468cf5;
    --accent: #e8a020;
    --danger: #dc3545;
    --success: #198754;
    --warning: #ffc107;
    --bg: #f0f4f8;
    --sidebar-w: 260px;
    --white: #ffffff;
    --text: #2d3748;
    --border: #dee2e6;
    --shadow: 0 2px 12px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* LOGIN */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}
.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-brand-logo {
    width: 100%;
    max-width: 300px;
    height: auto;
    display: block;
    margin: 0 auto 12px;
}
.login-logo p { color: #6c757d; font-size: 0.88rem; margin-top: 4px; }

/* LAYOUT */
.layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 { font-size: 1.1rem; font-weight: 700; }
.sidebar-header p { font-size: 0.78rem; opacity: 0.7; margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.82);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    border-left-color: var(--accent);
}
.sidebar-nav a .icon { font-size: 1.1rem; width: 22px; text-align: center; }

/* Submenú Configuración */
.sidebar-submenu-toggle {
    cursor: pointer;
    justify-content: space-between;
}
.sidebar-submenu-toggle .submenu-arrow {
    font-size: 0.65rem;
    margin-left: auto;
    opacity: 0.7;
    transition: transform 0.2s;
}
.sidebar-submenu-toggle.open .submenu-arrow { transform: rotate(180deg); }
.sidebar-submenu {
    background: rgba(0,0,0,0.15);
}
.sidebar-submenu a {
    padding-left: 44px;
    font-size: 0.85rem;
}
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.9);
}
.sidebar-user-icon { font-size: 1.1rem; }
.sidebar-user-name { font-weight: 600; }
.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px 0;
    background: #c0392b;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-logout:hover { background: #e74c3c; }

/* MAIN */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    background: var(--white);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h3 { font-size: 1.1rem; color: var(--primary); }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.badge-rol {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-rol.admin { background: #fff3cd; color: #856404; }
.badge-rol.estandar { background: #d1ecf1; color: #0c5460; }

.page-content { padding: 28px; flex: 1; }

/* CARDS */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.card-header h4 { font-size: 1.05rem; color: var(--primary); }

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--primary-light);
}
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .lbl { font-size: 0.82rem; color: #6c757d; margin-top: 4px; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,168,0.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.1s;
    text-decoration: none;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary-light); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger  { background: var(--danger); color: var(--white); }
.btn-warning { background: var(--warning); color: #212529; }
.btn-secondary { background: #6c757d; color: var(--white); }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary-light);
    color: var(--primary-light);
}

/* TABLE */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
    background: var(--primary);
    color: var(--white);
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 10px 14px; vertical-align: middle; }

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-disponible { background: #d1fae5; color: #065f46; }
.badge-prestado   { background: #fee2e2; color: #991b1b; }
.badge-activo     { background: #fef3c7; color: #92400e; }
.badge-devuelto   { background: #d1fae5; color: #065f46; }
.badge-vencido    { background: #fee2e2; color: #991b1b; }

/* SEARCH */
.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}
.search-bar input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
    width: 260px;
}
.search-bar input:focus { outline: none; border-color: var(--primary-light); }

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--white);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    animation: slideIn 0.2s ease;
}
.modal-lg { max-width: 780px; }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h5 { font-size: 1.05rem; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: #6c757d; line-height: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* CARRITO */
.carrito-panel {
    position: fixed;
    right: 0; top: 0;
    width: 360px;
    height: 100vh;
    background: var(--white);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 150;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s;
}
.carrito-panel.open { transform: translateX(0); }
.carrito-header {
    padding: 20px;
    background: var(--primary);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.carrito-body { flex: 1; overflow-y: auto; padding: 16px; }
.carrito-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.carrito-item .info { flex: 1; }
.carrito-item .info strong { display: block; }
.carrito-item .info span { color: #6c757d; font-size: 0.78rem; }
.carrito-footer { padding: 16px; border-top: 1px solid var(--border); }
.carrito-badge {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--danger);
    color: var(--white);
    border-radius: 50%;
    width: 20px; height: 20px;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.btn-carrito-float {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 50px;
    padding: 14px 22px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 140;
    transition: background 0.2s;
}
.btn-carrito-float:hover { background: var(--primary-light); }
.carrito-count {
    background: var(--danger);
    color: var(--white);
    border-radius: 50%;
    width: 22px; height: 22px;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* COMPROBANTE */
.comprobante {
    font-family: 'Courier New', monospace;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
    border: 2px solid var(--primary);
    border-radius: 8px;
}
.comprobante-header { text-align: center; border-bottom: 2px dashed var(--primary); padding-bottom: 16px; margin-bottom: 16px; }
.comprobante-header h3 { color: var(--primary); font-size: 1.2rem; }
.comprobante-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.88rem; }
.comprobante-items { margin: 16px 0; border-top: 1px dashed #ccc; border-bottom: 1px dashed #ccc; padding: 12px 0; }
.comprobante-item { padding: 4px 0; font-size: 0.85rem; }

/* ALERTS */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.88rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .carrito-panel { width: 100%; }
}

/* Paginación */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.85rem; color: #6c757d; }
.pagination-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-links .btn { min-width: 34px; text-align: center; padding: 5px 8px; font-size: 0.82rem; }
.pagination-links .btn.disabled { pointer-events: none; opacity: 0.4; }

/* Reportes */
.reporte-resumen {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.reporte-stat {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}
.reporte-stat-num {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}
.reporte-stat-label {
    font-size: 0.82rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
@media (max-width: 700px) {
    .reporte-resumen { grid-template-columns: 1fr 1fr; }
}

/* Pestañas */
.tabs-wrap {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 22px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    background: var(--white);
    border: 1.5px solid var(--primary);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
}
.tab-btn:hover {
    background: var(--primary);
    color: var(--white);
}
.tab-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(45,111,182,0.25);
    font-weight: 600;
}
