/* ===== RESET ===== */

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    font-family:'Segoe UI',sans-serif;
}

/* ===== BODY ===== */

body{

    background:linear-gradient(
    135deg,
    #f1f3f8,
    #e8eef7);

    min-height:100vh;

    color:#333;
}

/* ===== NAVBAR ===== */

.navbar{

    background:#1E3A6E;

    padding:15px 30px;

    display:flex;

    justify-content:space-between;

    align-items:center;

    box-shadow:
    0 3px 12px rgba(0,0,0,.15);

}

.logo{

    color:white;

    font-size:22px;

    font-weight:bold;
}

.nav-links a{

    color:white;

    text-decoration:none;

    margin-left:20px;

    transition:.3s;
}

.nav-links a:hover{

    opacity:.7;
}

/* ===== CONTENEDOR ===== */

.container{

    width:90%;

    max-width:1200px;

    margin:30px auto;
}

/* ===== TARJETAS ===== */

.card{

    background:white;

    border-radius:20px;

    padding:25px;

    margin-bottom:25px;

    box-shadow:
    0 4px 15px rgba(0,0,0,.08);
}

/* ===== TÍTULOS ===== */

h1,h2{

    color:#1E3A6E;

    margin-bottom:20px;
}

/* ===== BOTONES ===== */

.btn{

    border:none;

    padding:12px 18px;

    border-radius:10px;

    cursor:pointer;

    text-decoration:none;

    display:inline-block;

    color:white;

    font-weight:bold;
}

.btn-primary{

    background:#1A4FA0;
}

.btn-success{

    background:#28a745;
}

.btn-danger{

    background:#dc3545;
}

.btn-warning{

    background:#ffc107;

    color:black;
}

/* ===== BOTÓN ICONO ===== */

.btn-icon{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:34px;
    height:34px;
    padding:0;
    border-radius:8px;
    border:none;
    cursor:pointer;
    text-decoration:none;
    color:white;
    transition:opacity .2s, transform .15s;
    position:relative;
}

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

.btn-icon svg{
    pointer-events:none;
}

/* ===== BOTÓN VOLVER ===== */

.back-btn {
    position: fixed;
    left: max(16px, calc((100vw - 1200px) / 4));
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 14px rgba(0,0,0,.13);
    color: #1E3A6E;
    text-decoration: none;
    transition: box-shadow .2s, transform .2s;
    z-index: 100;
}

.back-btn:hover {
    box-shadow: 0 6px 22px rgba(0,0,0,.2);
    transform: translateY(-50%) scale(1.1);
}

/* ===== BADGES ===== */

.badge{
    padding:6px 10px;
    border-radius:8px;
    font-weight:bold;
    display:inline-block;
}

/* Estados de usuario */
.badge-activo        { background:rgba(40,167,69,.15);  color:#1a6b2e; border:1px solid rgba(40,167,69,.35); }
.badge-inactivo      { background:rgba(220,53,69,.15);  color:#8b1a26; border:1px solid rgba(220,53,69,.35); }

/* Roles */
.badge-admin         { background:rgba(0,123,255,.15);  color:#004494; border:1px solid rgba(0,123,255,.35); }
.badge-bibliotecario { background:rgba(23,162,184,.15); color:#0c6674; border:1px solid rgba(23,162,184,.35); }
.badge-usuario       { background:rgba(108,117,125,.15);color:#3a4147; border:1px solid rgba(108,117,125,.35); }

/* Estados de libro */
.badge-disponible    { background:rgba(40,167,69,.15);  color:#1a6b2e; border:1px solid rgba(40,167,69,.35); }
.badge-reservado     { background:rgba(255,193,7,.15);  color:#7d5a00; border:1px solid rgba(255,193,7,.45); }
.badge-agotado       { background:rgba(220,53,69,.15);  color:#8b1a26; border:1px solid rgba(220,53,69,.35); }

/* Estados de préstamo */
.badge-devuelto      { background:rgba(23,162,184,.15); color:#0c6674; border:1px solid rgba(23,162,184,.35); }
.badge-vencido       { background:rgba(220,53,69,.15);  color:#8b1a26; border:1px solid rgba(220,53,69,.35); }

/* ===== INPUTS ===== */

input,
select{

    width:100%;

    padding:12px;

    border-radius:10px;

    border:1px solid #ddd;

    margin-top:8px;

    margin-bottom:15px;
}

/* ===== TABLAS ===== */

table{

    width:100%;

    border-collapse:collapse;

    background:white;

    border-radius:15px;

    overflow:hidden;

    box-shadow:
    0 4px 10px rgba(0,0,0,.08);
}

table th{

    background:#1E3A6E;

    color:white;

    padding:15px;

    text-align:center;
}

table td{

    padding:15px;

    border-bottom:1px solid #eee;

    text-align:center;
}

table tr:hover{

    background:#f8f9fb;
}

.alert-danger{

background:#f8d7da;
color:#721c24;

padding:15px;
border-radius:10px;
margin-bottom:15px;

border-left:5px solid #dc3545;
}

.form-label {
    font-weight: 600;
}

.strength-bar {
    height: 6px;
    border-radius: 6px;
    background: #e9ecef;
    margin-top: 10px;
    overflow: hidden;
}

.strength-fill {
    height: 100%;
    border-radius: 6px;
    width: 0;
    transition: width 0.25s ease, background 0.25s ease;
}

.strength-label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 6px;
}

.role-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.role-badge {
    font-size: 0.8rem;
    padding: 5px 10px;
    border-radius: 999px;
}

.role-admin { background: rgba(30,58,110,0.1); color: #1e3a6e; }
.role-bib   { background: rgba(26,79,160,0.1); color: #1a4fa0; }
.role-user  { background: rgba(39,174,96,0.1); color: #1e8449; }

/* ===== HAMBURGER BUTTON ===== */

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform .3s, opacity .3s;
}

.nav-toggle.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.nav-toggle.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ===== TABLE WRAPPER (horizontal scroll) ===== */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 15px;
}

/* ===== RESPONSIVE — TABLET (≤992px) ===== */

@media (max-width: 992px) {
    .back-btn {
        left: 12px;
    }
}

/* ===== RESPONSIVE — MOBILE (≤768px) ===== */

@media (max-width: 768px) {

    /* Navbar */
    .navbar {
        position: relative;
        flex-wrap: wrap;
        padding: 12px 18px;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: 8px 0 4px;
        border-top: 1px solid rgba(255,255,255,.15);
        margin-top: 10px;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        margin-left: 0;
        padding: 10px 4px;
        border-bottom: 1px solid rgba(255,255,255,.08);
        font-size: 0.97rem;
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    /* Container */
    .container {
        width: 96%;
        margin: 16px auto;
    }

    /* Back button */
    .back-btn {
        position: fixed;
        left: 12px;
        top: auto;
        bottom: 24px;
        transform: none;
    }

    .back-btn:hover {
        transform: scale(1.1);
    }

    /* Tables */
    table {
        min-width: 520px;
    }

    /* Inputs — prevent iOS auto-zoom */
    input,
    select,
    textarea {
        font-size: 16px;
    }

    /* Dashboard grid */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    /* Buttons */
    .btn {
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    /* Auth card (recuperar) */
    .auth-card {
        width: 100% !important;
        max-width: 420px;
        margin: 20px auto;
        padding: 28px 20px !important;
        box-sizing: border-box;
    }

    .auth-container {
        padding: 16px;
        align-items: flex-start;
        padding-top: 40px;
    }
}

/* ===== RESPONSIVE — SMALL MOBILE (≤480px) ===== */

@media (max-width: 480px) {
    .logo {
        font-size: 18px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .dash-card {
        padding: 20px 14px;
    }

    .dash-card-icon {
        width: 48px;
        height: 48px;
    }
}

/* ===== STAR RATING ===== */

/* Promedio (solo lectura) */
.stars-display {
    display: inline-flex;
    gap: 1px;
    line-height: 1;
}

.star {
    font-size: 1.15rem;
}

.star-filled {
    color: #f4c430;
}

.star-empty {
    color: #ddd;
}

.stars-meta {
    font-size: 0.78rem;
    color: #555;
    margin-top: 2px;
}

/* Widget interactivo (rol usuario) */
.star-form {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* Estrellas en orden inverso para que el selector CSS funcione */
.star-rating {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 1px;
}

.star-rating input[type="radio"] {
    display: none;
}

.star-rating label {
    cursor: pointer;
    font-size: 1.35rem;
    color: #ddd;
    transition: color .1s;
    line-height: 1;
}

/* Estrella marcada y todas las que la siguen (visualmente anteriores) */
.star-rating input[type="radio"]:checked ~ label {
    color: #f4c430;
}

/* Botón enviar calificación */
.btn-rate {
    background: #1A4FA0;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}

.btn-rate:hover {
    background: #1E3A6E;
}

