/* ============================================================ */
/* ESTILOS BASE                                                */
/* ============================================================ */
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding-top: 160px; /* Espacio para header fijo de dos partes (75px + 75px + margen) */
}

/* ============================================================ */
/* HEADER - ESTRUCTURA DE DOS PARTES                           */
/* ============================================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.115);
}

/* --- Parte superior: imagen cabecera con info de usuario --- */
.header-cabecera {
    height: 75px;
    background-image: url('cabecera.png');
    background-size: cover;
    background-position: center top;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-avatar {
    height: 45px;
    width: auto;
}

.header-welcome {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.btn-logout-header {
    background: rgba(255, 255, 255, 0.18);
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-logout-header:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* --- Parte inferior: barra de navegación blanca --- */
.header-navbar {
    background-color: #f8f9fa;
    min-height: 75px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid #e5e7eb;
}

/* ============================================================ */
/* MENÚ DE NAVEGACIÓN                                          */
/* ============================================================ */

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    height: 75px;
}

.nav-menu > li {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-menu > li > a {
    color: #333;
    text-decoration: none;
    padding: 0 16px;
    display: flex;
    align-items: center;
    height: 100%;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s, background-color 0.2s;
    white-space: nowrap;
}

.nav-menu > li > a:hover,
.nav-menu > li:hover > a {
    color: #2c8437;
    background-color: rgba(0, 0, 0, 0.04);
}

/* Dropdown menus */
.nav-menu .dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 210px;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    list-style: none;
    padding: 4px 0;
    margin: 0;
}

.nav-menu li:hover > .dropdown {
    display: block;
}

.nav-menu .dropdown li {
    height: auto;
    display: block;
}

.nav-menu .dropdown li a {
    color: #444;
    padding: 9px 16px;
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    height: auto;
    text-decoration: none;
    transition: background 0.15s, padding-left 0.15s;
    border-bottom: 1px solid #f3f4f6;
}

.nav-menu .dropdown li:last-child a {
    border-bottom: none;
}

.nav-menu .dropdown li a:hover {
    background-color: #f3f4f6;
    color: #2c8437;
    padding-left: 22px;
}

/* Logo en la barra de navegación */
.header-logo img {
    max-height: 62px;
    width: auto;
}

/* ============================================================ */
/* CONTENIDO PRINCIPAL                                         */
/* ============================================================ */

main {
    width: 90%;
    max-width: 1200px;
    margin: 2rem auto;
    min-height: 70vh;
}

/* ============================================================ */
/* PIE DE PÁGINA                                               */
/* ============================================================ */

.site-footer {
    margin-top: 4rem;
    background-color: #111827;
}

.footer-inner {
    display: flex;
    align-items: center;
}

.footer-image-area {
    flex-shrink: 0;
    line-height: 0;
}

.footer-img {
    max-height: 180px;
    display: block;
}

.footer-info {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 30px;
    padding: 24px 30px;
    font-family: Arial, sans-serif;
    font-size: 80%;
}

.footer-contact,
.footer-desc {
    text-align: right;
    max-width: 300px;
}

.footer-contact p,
.footer-desc p {
    margin: 5px 0;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.6;
}

/* ============================================================ */
/* DASHBOARD (main.html)                                       */
/* ============================================================ */

.dashboard-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-container img {
    max-width: 300px;
    height: auto;
    margin-bottom: 1rem;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.card h3 {
    color: #2c8437;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* ============================================================ */
/* IMÁGENES PRINCIPALES                                        */
/* ============================================================ */

.main-title {
    color: #2c8437;
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #2c8437;
}

.image-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2rem;
    margin: 2rem 0;
}

.image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.image-container img:hover {
    transform: scale(1.03);
}

/* ============================================================ */
/* FORMULARIOS - CONTENEDOR                                    */
/* ============================================================ */

.form-container {
    max-width: 850px;
    margin: 0 auto;
    padding: 0;
}

.form-title {
    color: #1e3a8a;
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    border-bottom: 2px solid #e5e7eb;
}

/* ============================================================ */
/* PESTAÑAS / TABS                                             */
/* ============================================================ */

.tabs {
    display: flex;
    border-bottom: none;
    margin-bottom: 0;
}

.tab-link {
    cursor: pointer;
    padding: 0.65rem 1.5rem;
    background-color: #1e40af;
    border: none;
    border-radius: 6px 6px 0 0;
    margin-right: 4px;
    font-weight: 600;
    color: white;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    display: inline-block;
    text-decoration: none;
}

.tab-link:hover {
    background-color: #1e3a8a;
    color: white;
}

.tab-link.active {
    background-color: #1e40af;
    color: white;
}

.tab-content {
    display: none;
    padding: 2rem 2.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0 6px 6px 6px;
    box-shadow: 0 0 12px rgba(198, 198, 198, 0.6);
}

.tab-content.active {
    display: block;
}

/* ============================================================ */
/* FORMULARIOS - CAMPOS COMUNES                                */
/* ============================================================ */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #444;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border 0.3s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #2c8437;
    outline: none;
    box-shadow: 0 0 0 2px rgba(44, 132, 55, 0.1);
}

.form-group input[type="datetime-local"] {
    padding: 0.7rem;
}

.form-actions {
    margin-top: 2rem;
    text-align: center;
}

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

button {
    background-color: #16a34a;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin: 0 0.5rem;
}

button:hover {
    background-color: #15803d;
}

button.secondary {
    background-color: #6c757d;
}

button.secondary:hover {
    background-color: #5a6268;
}

/* ============================================================ */
/* TABLAS DE CONSULTA                                          */
/* ============================================================ */

.consulta-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    font-size: 0.95rem;
}

.consulta-table th {
    background-color: #16a34a;
    color: white;
    padding: 1rem;
    text-align: left;
}

.consulta-table td {
    padding: 1rem;
    border: 1px solid #ddd;
}

.consulta-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.consulta-table tr:hover {
    background-color: #f1f1f1;
}

/* ============================================================ */
/* VALIDACIÓN                                                  */
/* ============================================================ */

input:invalid {
    border-color: #dc3545;
}

.validation-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

input:invalid + .validation-message {
    display: block;
}

.required-field::after {
    content: " *";
    color: #dc3545;
}

/* ============================================================ */
/* AUTOCOMPLETADO DE USUARIOS                                  */
/* ============================================================ */

.sugerencias-container {
    position: relative;
    width: 100%;
}

.lista-sugerencias {
    position: absolute;
    z-index: 1000;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-top: -4px;
}

.sugerencia-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
    transition: background-color 0.2s;
}

.sugerencia-item:last-child {
    border-bottom: none;
}

.sugerencia-item:hover {
    background-color: #f5f5f5;
    color: #2c8437;
}

.coincidencia {
    font-weight: bold;
    color: #246b2e;
}

.input-con-sugerencias {
    border-radius: 4px 4px 0 0 !important;
    border-bottom: 1px solid #ddd !important;
    box-shadow: none !important;
}

/* ============================================================ */
/* CAMPOS ESPECIALES                                           */
/* ============================================================ */

.readonly-field {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* ============================================================ */
/* PAGINACIÓN                                                  */
/* ============================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* ============================================================ */
/* LOGIN - Diseño v2                                           */
/* ============================================================ */

body.login-v2 {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-top: 20px;
}

.login-container-v2 {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header-v2 {
    background-color: #f3f3f3;
    color: rgb(0, 0, 0);
    padding: 25px;
    text-align: center;
}

.login-header-v2 h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-header-v2 p {
    font-size: 14px;
    opacity: 0.9;
}

.logo-container-v2 {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.logo-v2 {
    height: 90px;
    margin: 0 10px;
}

.login-form-v2 {
    padding: 25px;
}

.form-group-v2 {
    margin-bottom: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form-group-v2 label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group-v2 input {
    width: 100%;
    max-width: 300px;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group-v2 input:focus {
    border-color: #4caf50;
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.btn-login-v2 {
    width: 100%;
    padding: 14px;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-login-v2:hover {
    background-color: #388e3c;
}

.btn-login-v2:active {
    transform: translateY(1px);
}

.message-v2 {
    margin-top: 20px;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    display: none;
}

.error-v2 {
    background-color: #ffebee;
    color: #d32f2f;
    border: 1px solid #f44336;
}

.success-v2 {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.loading-v2 {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
    vertical-align: middle;
}

.footer-v2 {
    text-align: center;
    margin-top: 20px;
    color: #666;
    font-size: 12px;
}

/* ============================================================ */
/* RESPONSIVE                                                  */
/* ============================================================ */

@media (max-width: 768px) {
    body {
        padding-top: 85px;
    }

    .header-cabecera {
        height: 65px;
    }

    .header-navbar {
        flex-wrap: wrap;
        padding: 8px 16px;
        min-height: auto;
        gap: 8px;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
        height: auto;
        display: none;
    }

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

    .nav-menu > li {
        width: 100%;
        height: auto;
        display: block;
    }

    .nav-menu > li > a {
        padding: 12px 16px;
        height: auto;
        width: 100%;
        display: block;
    }

    .nav-menu .dropdown {
        position: static;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        border: none;
        background: #f8f9fa;
    }

    .header-logo img {
        max-height: 45px;
    }

    .form-container {
        padding: 0 1rem;
    }

    .tab-content {
        padding: 1rem 1.2rem;
    }

    .footer-inner {
        flex-direction: column;
    }

    .footer-img {
        width: 100%;
        max-height: 120px;
        object-fit: cover;
    }

    .footer-info {
        flex-direction: column;
        padding: 16px 20px;
        gap: 12px;
    }

    .footer-contact,
    .footer-desc {
        text-align: center;
        max-width: 100%;
    }

    .consulta-table {
        display: block;
        overflow-x: auto;
    }

    .consulta-table td {
        white-space: nowrap;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
