/* ==========================================================================
   VARIABLES Y TEMAS
   ========================================================================== */
:root {
    --bg-color: #e0e5ec; 
    --card-bg: #e0e5ec;
    --text-main: #2d3436;
    --text-sec: #636e72;
    --accent: #2ecc71;         
    --accent-hover: #27ae60;
    --shadow-dark: #b8bec5;
    --shadow-light: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #1b1d20;
    --card-bg: #1b1d20;
    --text-main: #f5f6fa;
    --text-sec: #b2bec3;
    --shadow-dark: #121315;
    --shadow-light: #24272b;
}

/* ==========================================================================
   ESTILOS BASE
   ========================================================================== */
body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

header { text-align: center; margin-bottom: 50px; }

/* ==========================================================================
   BUSCADOR Y AUTOCOMPLETADO (Proporciones corregidas)
   ========================================================================== */
.search-box {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 700px;
    margin: 40px auto;
    background: var(--card-bg);
    padding: 10px 10px 10px 20px;
    border-radius: 20px;
    box-shadow: 6px 6px 12px var(--shadow-dark), 
                -6px -6px 12px var(--shadow-light);
    position: relative;
}

/* Contenedor del input */
.search-box > div:first-child {
    flex: 1; 
    position: relative;
    display: flex;
}

.search-box input {
    width: 100%;
    border: none;
    padding: 12px 15px;
    font-size: 1rem;
    outline: none;
    background: transparent;
    color: var(--text-main);
    box-shadow: inset 2px 2px 5px var(--shadow-dark), 
                inset -2px -2px 5px var(--shadow-light);
    border-radius: 12px;
}

.search-box button {
    flex-shrink: 0; /* Evita que el botón se estire con las sugerencias */
    white-space: nowrap;
    background: var(--accent);
    color: white;
    border: none;
    height: 48px;
    padding: 0 30px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 4px 4px 10px var(--shadow-dark), 
                -2px -2px 10px var(--shadow-light);
    transition: all 0.2s ease;
}

.search-box button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.sugerencias-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 10px 10px 20px var(--shadow-dark);
    z-index: 5000;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--shadow-light);
}

/* ==========================================================================
   GRID DE LIBROS
   ========================================================================== */
.grid-libros {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 30px;
    margin-top: 30px;
}

.libro-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 8px 8px 16px var(--shadow-dark), 
                -8px -8px 16px var(--shadow-light);
    transition: transform 0.3s ease;
}

.libro-card:hover { transform: translateY(-5px); }

.libro-card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: inset 2px 2px 5px var(--shadow-dark), 
                inset -2px -2px 5px var(--shadow-light);
}

/* ==========================================================================
   ACCIONES (Eliminando la doble flecha)
   ========================================================================== */
.libro-acciones {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
}

.select-wrapper {
    position: relative;
    flex: 1;
}

select.btn-status {
    width: 100%;
    /* Elimina flecha nativa en todos los navegadores */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    
    background: var(--card-bg);
    border: none;
    padding: 8px 30px 8px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: inset 3px 3px 6px var(--shadow-dark), 
                inset -3px -3px 6px var(--shadow-light);
    outline: none;
}

.btn-eliminar {
    background: var(--card-bg);
    color: #ff7675;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 4px 4px 8px var(--shadow-dark), 
                -4px -4px 8px var(--shadow-light);
}

.btn-eliminar:active {
    box-shadow: inset 2px 2px 4px var(--shadow-dark), 
                inset -2px -2px 4px var(--shadow-light);
}

/* ==========================================================================
   MODAL (Limpieza de texto fantasma)
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    z-index: 9999;
}

.modal-content {
    background: var(--card-bg);
    margin: 10% auto;
    padding: 20px;
    width: 80%;
    max-width: 600px;
    border-radius: 20px;
    box-shadow: 10px 10px 20px var(--shadow-dark);
}

/* Ocultar texto alt si la imagen no carga */
#modal-portada {
    max-width: 100%;
    border-radius: 12px;
    color: transparent;
}

#modal-portada[src=""] { display: none; }

/* ==========================================================================
   FOOTER (Centrado Real)
   ========================================================================== */
footer {
    width: 100%;
    margin-top: 60px;
    padding: 30px 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-sec);
    border-top: 1px solid var(--shadow-dark);
    display: block;
    clear: both;
}

footer span#year {
    font-weight: bold;
    color: var(--accent);
}

/* ==========================================================================
   TEMA OSCURO / RESPONSIVE
   ========================================================================== */
.theme-switch {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-main);
    border: none;
    box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
    cursor: pointer;
    z-index: 10000;
}

@media (max-width: 480px) {
    .grid-libros { 
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    }
}

/* ==========================================================================
   ANIMACIÓN DEL ICONO (Libro flotante)
   ========================================================================== */
.header-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 15px;
    filter: drop-shadow(0 5px 15px rgba(46, 204, 113, 0.4));
    /* Llamamos a la animación: nombre | duración | suavizado | infinito */
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px); /* Sube un poquito */
    }
    100% {
        transform: translateY(0px); /* Vuelve a bajar */
    }
}

/* Estilo para el subtítulo verde bajo el título principal */
h1 span {
    display: block;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: white;
    font-weight: 400;
    margin-top: 5px;
}

.modal-rating { margin-top: 20px; }

.stars {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-sec);
}

.stars span.active {
    color: #f1c40f; /* Dorado para estrellas marcadas */
    text-shadow: 0 0 10px rgba(241, 196, 15, 0.4);
}

.modal-notas textarea {
    width: 100%;
    height: 80px;
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    background: var(--card-bg);
    border: none;
    box-shadow: inset 2px 2px 5px var(--shadow-dark), 
                inset -2px -2px 5px var(--shadow-light);
    color: var(--text-main);
    resize: none;
    outline: none;
}

.btn-guardar {
    margin-top: 10px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 4px 4px 8px var(--shadow-dark);
}
.stars-card span {
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-sec);
    transition: color 0.2s;
}

.stars-card span.active {
    color: #f1c40f;
}

.btn-exportar {
    background: var(--card-bg);
    color: var(--text-main);
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    margin: 10px;
    box-shadow: 4px 4px 8px var(--shadow-dark), 
                -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
}

.btn-exportar:hover {
    color: var(--accent);
    transform: translateY(-2px);
}


.header-subtitle {
    font-style: italic;
    font-weight: 300;
    min-height: 1.5em; 
    color: var(--text-sec);
    display: inline-block;
    border-right: 2px solid var(--accent); /* El cursor */
    padding-right: 5px;
    animation: blink-caret 0.75s step-end infinite;
}

/* Animación del cursor parpadeante */
@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: var(--accent) }
}