@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== Fix: contraste, separación en formularios y blur molesto ===== */

/* Variables base */
:root {
    --bg-page: #f6f7fb;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #1f2937;
    --text-muted: #4b5563;
    --primary: #3746ef;
    --danger: #ef4444;
}

/* Asegurar color de fondo y texto generales */
body {
    background-color: var(--bg-page) !important;
    color: var(--text) !important;
    -webkit-font-smoothing:antialiased;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    color: var(--text-dark) !important;
    background: url('../images/escuela-background.jpg') no-repeat center center fixed;
    background-size: cover;
}

/* Overlay para mejorar legibilidad */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: -1;
}

/* Tarjetas / contenedores con fondo blanco y sombra */
.card, .panel, .login-card, .doc-card {
    background: var(--card-bg) !important;
    color: var(--text-dark) !important;
    box-shadow: 0 6px 18px rgba(15,23,42,0.06);
    border-radius: 10px;
}

/* Forzar color y contraste en todos los textos dentro de secciones problemáticas */
header, nav, .navbar, .page, .content, .panel, .card, .form-control, input, textarea, button, a {
    color: var(--text-dark) !important;
}

/* Evitar que una capa blur/overlay deje el fondo blanco + texto blanco */
.overlay, .backdrop, .blur-bg, .bg-blur {
    background: var(--muted-bg) !important;
    color: var(--text) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

/* Formularios: inputs y botones en bloque, separación y contraste */
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="file"],
form textarea,
.form-control {
    display: block !important;
    width: 100% !important;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem !important;
    border: 1px solid #e6e9ef;
    border-radius: 6px;
    background: #fff;
    color: var(--text-dark) !important;
}

/* Botones principales */
button, .btn, .btn-primary {
    display: inline-block;
    padding: 0.55rem 0.9rem;
    background: var(--primary);
    color: #fff !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
    margin-bottom: 0.5rem;
}
button:hover, .btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(55,70,239,0.12); }

/* Si el input y el botón están en la misma línea, forzamos separación */
input + button, input + .btn, .form-control + .btn {
    margin-top: 0.25rem;
}

/* Enlaces y texto claro accidental */
a, .nav-link {
    color: var(--primary) !important;
    text-decoration: none;
}

/* Pequeñas mejoras responsive para formularios */
@media (max-width: 640px) {
    .doc-card { width: 100% !important; }
    form input, form textarea, button { font-size: 15px; }
}

/* Estilos generales */
:root {
    --primary-color: #2563eb; /* Azul moderno */
    --secondary-color: #f3f4f6; /* Fondo gris claro */
    --accent-color: #10b981; /* Verde esmeralda */
    --warning-color: #f59e0b; /* Amarillo cálido */
    --error-color: #ef4444; /* Rojo coral */
    --text-color: #1f2937; /* Gris oscuro */
    --heading-color: #111827;
    --card-bg: #ffffffcc;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
    --border-radius: 14px;
    --transition: all 0.25s ease;
}

body {
    background: linear-gradient(180deg, #e0e7ff 0%, #f9fafb 100%);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 20px;
    color: var(--text-color);
    line-height: 1.6;

    background-image: url('https://images.unsplash.com/photo-1507842217343-583bb7270b66?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-attachment: fixed;
    background-blend-mode: overlay;
}

/* Contenedores */
.container, .admin-container {
    max-width: 980px;
    margin: 30px auto;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2.2em;
    transition: var(--transition);
}

.container:hover {
    transform: translateY(-2px);
}

/* Tarjetas */
.card {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5em;
    margin-bottom: 2em;
    transition: var(--transition);

    background-image: url('https://images.unsplash.com/photo-1507842217343-583bb7270b66?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');
    background-size: cover;
    background-position: center;
}

.container, .admin-container {
    max-width: 960px;
    margin: 20px auto;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2em;
    overflow-x: auto; /* Permite el desplazamiento horizontal si es necesario */

}

.card:hover {
    transform: translateY(-3px);
}

/* Encabezado */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2em;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 1em;
}

.header h2 {
    color: var(--heading-color);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header .user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header .user-profile img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

/* Botones */
button, .btn {
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: #fff;
    display: inline-block;
}

button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: var(--primary-color);
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-success {
    background: var(--accent-color);
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--error-color);
}

.btn-secondary {
    background: #6b7280;
}

/* Formularios */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 15px;
    transition: var(--transition);
    background-color: #f9fafb;
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    background-color: #fff;
}

/* Tablas */
table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 2em;
}

th {
    background: var(--primary-color);
    color: #fff;
    padding: 14px;
    text-align: left;
    font-weight: 600;
}


td {
    padding: 14px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

tbody tr:hover td {
    background: #f3f4f6;
}
tbody tr {
    background-color: #fff;
}

tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

tbody tr:hover {
    background-color: #f1f1f1;
}

/* Secciones de la página */
.table-section {
    margin-bottom: 2.5em;
}

/* Títulos de secciones */
.table-section h3 {
    color: var(--heading-color);
    border-left: 5px solid var(--primary-color);
    padding-left: 12px;
    margin-bottom: 1.2em;
    font-weight: 700;
}

/* Flash Messages */
.flash-message {
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 1.5em;
    text-align: center;
    font-weight: 500;
}

.flash-success {
    background-color: #dcfce7;
    color: #166534;
}

.flash-error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Login */
.login-container {
    max-width: 420px;
    margin: 70px auto;
    background: rgba(255, 255, 255, 0.95) !important; /* Fondo más opaco */
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 2.5em;
    text-align: center;
}

.login-container h2,
.login-container p,
.login-container label,
.login-container small {
    color: #1f2937 !important; /* Color oscuro para mejor legibilidad */
    text-shadow: none !important;
    margin-bottom: 1rem;
}

.login-container input[type="email"] {
    background: white !important;
    border: 1px solid #d1d5db !important;
    color: #1f2937 !important;
    padding: 12px;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.login-container .btn {
    background: var(--primary-color);
    color: white !important;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 1rem;
    border: none;
}

.flash-message {
    background: white !important;
    color: #1f2937 !important;
    border: 1px solid #e5e7eb;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.flash-error {
    background: #fef2f2 !important;
    color: #991b1b !important;
    border-color: #fecaca;
}

.flash-success {
    background: #f0fdf4 !important;
    color: #166534 !important;
    border-color: #dcfce7;
}

/* Media Queries for Mobile */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container, .admin-container {
        padding: 1em;
        margin: 10px auto;
    }

    .header {
        flex-direction: column;
        gap: 1em;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }

    td:before {
        position: absolute;
        left: 10px;
        width: calc(50% - 20px);
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        content: attr(data-label);
    }
    
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"] {
        width: calc(100% - 20px);
    }
}


@media (max-width: 600px) {
    .login-container {
        width: 90%;
        padding: 1.5em;
    }
}

.login-container h2 {
    margin-bottom: 1em;
    color: var(--heading-color);
}

/* Buscador biblioteca virtual */
.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0.75rem 0 1.25rem 0;
}
.search-form input[type="text"],
.search-form input[type="search"],
.search-form input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e6e9ef;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
}
.search-form button, .search-form .btn-anim {
    padding: 0.5rem 0.85rem;
}
/* Asegura legibilidad en opciones del datalist (algunos navegadores usan fondo nativo) */
datalist option { color: var(--text); }

/* Animaciones y utilidades */
.page-fade { animation: fadeIn 400ms ease-out both; }
@keyframes fadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: translateY(0); } }

.doc-list { display:flex; flex-wrap:wrap; gap:1rem; }
.doc-card {
    background:#fff; border-radius:8px; padding:1rem; width:calc(33.333% - 1rem);
    box-shadow:0 1px 3px rgba(0,0,0,.06); transition:transform .18s, box-shadow .18s;
    animation: slideUp .35s ease both;
}
.doc-card:hover { transform: translateY(-6px) scale(1.01); box-shadow:0 8px 20px rgba(0,0,0,.12); }
@keyframes slideUp { from { opacity:0; transform:translateY(12px);} to { opacity:1; transform:translateY(0);} }

.btn-anim { transition: transform .12s, box-shadow .12s; }
.btn-anim:hover { transform: translateY(-3px); box-shadow:0 6px 16px rgba(0,0,0,.08); }

.upload-progress { height:8px; background:#eee; border-radius:6px; overflow:hidden; margin-top:.5rem; }
.upload-progress > i { display:block; height:100%; width:0%; background:linear-gradient(90deg,#4f46e5,#06b6d4); transition:width .2s linear; }

.spinner { width:36px; height:36px; border:4px solid #eee; border-top-color:#4f46e5; border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

.skeleton { background:linear-gradient(90deg,#efefef 25%,#f6f6f6 50%,#efefef 75%); background-size:200% 100%; animation:shimmer 1.2s linear infinite; border-radius:6px; }
@keyframes shimmer { to { background-position:-200% 0; } }

/* ===== estilos para admin_libros form ===== */
.book-form {
    background: #fff;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15,23,42,0.04);
    margin-bottom: 1.25rem;
}

.book-form .form-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: flex-start;
}

.book-form .field {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-form .field.small { flex: 0 0 110px; }

.book-form label {
    font-size: 0.85rem;
    color: #334155;
    margin-bottom: 0.35rem;
}

.book-form input[type="text"],
.book-form input[type="number"],
.book-form textarea,
.book-form input[type="email"],
.book-form .form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #e6e9ef;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    box-sizing: border-box;
}

.book-form textarea { resize: vertical; }

.book-form .form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.book-form .btn-anim {
    padding: 0.55rem 0.9rem;
    border-radius: 8px;
}

/* Responsive: en pantallas pequeñas apilar columnas */
@media (max-width: 760px) {
    .book-form .form-row { flex-direction: column; }
    .book-form .field.small { flex: 1; width: 100%; }
    .book-form { padding: 0.85rem; }
}

@media (max-width:900px){ .doc-card{ width:calc(50% - 1rem); } }
@media (max-width:600px){ .doc-card{ width:100%; } }

/* admin back button y lista documentos */
.admin-back{
    display:inline-flex;
    gap:.6rem;
    align-items:center;
    padding:.45rem .75rem;
    background:#f8fafc;
    border-radius:10px;
    color:#0f172a;
    text-decoration:none;
    border:1px solid #e6e9ef;
    font-weight:600;
}
.admin-back:hover{
    background:#ffffff;
    box-shadow:0 8px 22px rgba(15,23,42,0.06);
    transform:translateY(-2px);
}

.admin-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:0.75rem;
}

.doc-row{
    display:flex;
    align-items:center;
    gap:1rem;
    padding:.75rem;
    border-bottom:1px solid #f1f5f9;
}
.doc-row .meta { flex:1; min-width:0; }
.doc-row .meta .title { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.doc-row .meta .desc { color:#64748b; font-size:.95rem; margin-top:.25rem; overflow:hidden; text-overflow:ellipsis; display:-webkit-box;  -webkit-box-orient:vertical; }
.admin-actions{ display:flex; gap:.5rem; align-items:center; }
.admin-actions .btn-anim{ padding:.35rem .6rem; font-size:.9rem; border-radius:8px; }
.admin-actions .btn-danger{ background:#ef4444; color:#fff; border:none; }

@media (prefers-color-scheme: dark) {
:root {
    --bg-page: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.8);
    --text: #f1f5f9;
    --muted-text: #2e2f30;
    --primary: #3b82f6;
}

body {
    background: linear-gradient(180deg, #1e293b, #0f172a);
}

table th {
    background: var(--primary);
}

.card, .container {
    backdrop-filter: blur(10px);
}

input, textarea {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
}

/* Mejora de formulario de búsqueda y tarjetas en biblioteca virtual */
.search-form input, .search-form textarea {
    box-shadow: none;
    outline: none;
}
.doc-card { background: #fff; box-shadow: 0 8px 20px rgba(15,23,42,0.04); border: 1px solid #f1f5f9; padding: 1rem; border-radius: 10px; }
.search-form { gap: .6rem; }

body {
    background-color: transparent;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../images/escuela-background.jpeg');
    background-size: cover;
    background-position: center;
    filter: blur(1px);
    transform: scale(1.02); /* Small scale to prevent blurry edges */
    z-index: -1;/* ===== Mejoras de Contraste y Fondo v2 ===== */

/* 1. Eliminar fondos anteriores del body para evitar conflictos */
body {
    background: transparent !important;
}

/* 2. Ajustar el desenfoque del fondo para que la imagen sea más visible */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../images/escuela-background.jpeg');
    background-size: cover;
    background-position: center;
    filter: blur(2px); /* Desenfoque reducido */
    transform: scale(1.02);
    z-index: -1;
}

/* 3. Aumentar opacidad de contenedores y forzar texto oscuro para legibilidad */
.card, .container, .admin-container, .login-container {
    background-color: rgba(255, 255, 255, 0.94) !important; /* Fondo casi opaco */

}

.content-wrapper {
    position: relative;
    z-index: 1;
    background-color: rgba(255, 255, 255, 0.8); /* Example of a semi-transparent white background for content */
    padding: 20px;
    border-radius: 10px;
}

/* Forzar colores de texto oscuros para mejor contraste */
.card, .container, .admin-container, .login-container {
    background-color: rgba(255, 255, 255, 0.95) !important;
    color: #1f2937 !important;
}

/* Asegurar que todos los textos sean oscuros */
p, h1, h2, h3, h4, h5, h6, 
label, span, input, textarea,
table td, table th {
    color: #1f2937 !important;
}

/* Mejorar contraste en formularios */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
.form-control {
    color: #1f2937 !important;
    background-color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #d1d5db !important;
}

/* Mejorar contraste en tablas */
td {
    color: #1f2937 !important;
    background-color: rgba(255, 255, 255, 0.95) !important;
}

/* Asegurar que los enlaces sean visibles */
a, .nav-link {
    color: #2563eb !important;
    font-weight: 500;
}

/* Mejorar contraste en botones */
.btn, button {
    color: #ffffff !important;
    font-weight: 600;
}

/* Mejorar contraste en mensajes flash */
.flash-message {
    background-color: rgba(255, 255, 255, 0.95) !important;
    color: #1f2937 !important;
    border: 1px solid #d1d5db;
}

/* Mejorar contraste en el header */
.header h2, .header .user-profile {
    color: #1f2937 !important;
}

/* Mejorar contraste en la navegación */
.navbar {
    background-color: rgba(255, 255, 255, 0.95) !important;
}

/* Asegurar contraste en elementos de biblioteca virtual */
.doc-card {
    background-color: rgba(255, 255, 255, 0.95) !important;
}

.doc-card .title {
    color: #1f2937 !important;
    font-weight: 600;
}

.doc-card .desc {
    color: #4b5563 !important;
}

/* Mejorar contraste en el formulario de búsqueda */
.search-form input {
    background-color: rgba(255, 255, 255, 0.95) !important;
    color: #1f2937 !important;
}
/* ============================================================
    Responsive Master — Adaptación total a móviles y tablets
   ============================================================ */

/* Tablets medianas (pantallas <= 992px) */
@media (max-width: 992px) {
  body {
    padding: 15px;
    overflow-x: hidden;
  }

  .container, .admin-container {
    max-width: 95%;
    padding: 1.5em;
  }

  .header {
    flex-direction: column;
    gap: 1em;
    text-align: center;
  }

  .header h2 {
    font-size: 1.6rem;
  }

  .header .user-profile {
    flex-direction: column;
    align-items: center;
  }

  table {
    font-size: 15px;
  }

  .doc-list {
    gap: 0.75rem;
  }

  .book-form .form-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-form {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-form button {
    width: 100%;
  }
}

/* Móviles grandes (pantallas <= 768px) */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    overflow-x: hidden;
  }

  .container, .admin-container, .login-container {
    width: 100%;
    padding: 1.2em;
    margin: 0 auto;
  }

  .card, .doc-card {
    width: 100% !important;
    margin-bottom: 1.2rem;
  }

  .header {
    flex-direction: column;
    text-align: center;
    align-items: center;
    gap: 0.75rem;
  }

  .header h2 {
    font-size: 1.4rem;
  }

  .header .user-profile img {
    width: 40px;
    height: 40px;
  }

  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
  }

  td {
    border: none;
    padding: 8px 0;
    position: relative;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    width: 45%;
    font-weight: 600;
    color: #374151;
    text-align: left;
  }

  .book-form {
    padding: 1rem;
  }

  .book-form .btn-anim {
    width: 100%;
  }

  .flash-message {
    font-size: 0.95rem;
    padding: 0.8rem;
  }

  .btn, button {
    width: 100%;
    text-align: center;
    font-size: 14px;
    padding: 10px 14px;
  }

  .login-container {
    margin-top: 40px;
    padding: 1.5em;
  }
}

/* Móviles pequeños (pantallas <= 480px) */
@media (max-width: 480px) {
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  p, label, input, button, td { font-size: 14px; }

  .container, .admin-container {
    padding: 0.9em;
  }

  .search-form input {
    width: 100%;
  }

  .header {
    gap: 0.5rem;
  }

  .header h2 {
    font-size: 1.2rem;
  }

  .doc-list {
    flex-direction: column;
  }

  .doc-card {
    width: 100% !important;
    padding: 0.9rem;
  }

  .book-form .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .book-form .btn-anim {
    width: 100%;
  }

  .flash-message {
    font-size: 0.9rem;
  }
}

/* ============================================================
    Fin del bloque Responsive Master
   ============================================================ */


}