/* Variables de colores */
:root {
    --color-primary: #005CAB;
    --color-primary-dark: #003A6B;
    --color-secondary: #2c3e50;
    --color-accent: #34495e;
    --color-text: #333;
    --color-text-light: #666;
    --color-background: #f4f4f4;
    --color-white: #ffffff;
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning: #ffc107;
    --color-info: #17a2b8;
}

/* Reset y base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==================== */
/* HEADER MEJORADO PARA MÓVILES */
/* ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #005CAB 0%, #003A6B 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 70px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    height: 50px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.welcome-text {
    font-weight: 500;
    white-space: nowrap;
}

.btn-primary {
    background: white;
    color: #005CAB;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    border: 2px solid white;
    white-space: nowrap;
}

.btn-primary:hover {
    background: transparent;
    color: white;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Overlay para menú móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

/* ==================== */
/* MEDIA QUERIES PARA HEADER MÓVIL */
/* ==================== */
@media (max-width: 1024px) {
    .header {
        padding: 12px 16px;
        min-height: 65px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .welcome-text {
        font-size: 14px;
    }
    
    .btn-primary {
        padding: 7px 14px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
        min-height: 60px;
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
        font-size: 22px;
        order: -1;
        margin-right: 10px;
    }
    
    .header h1 {
        font-size: 16px;
        max-width: 200px;
    }
    
    .welcome-text {
        display: none;
    }
    
    .btn-primary {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .logo {
        height: 40px;
        max-width: 100px;
    }
    
    /* Ajustar container para header fijo */
    .container {
        margin-top: 60px;
        height: calc(100vh - 60px);
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 10px;
        min-height: 55px;
    }
    
    .header h1 {
        font-size: 14px;
        max-width: 150px;
    }
    
    .mobile-menu-btn {
        font-size: 20px;
        padding: 4px;
    }
    
    .btn-primary {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .logo {
        height: 35px;
        max-width: 80px;
    }
    
    .container {
        margin-top: 55px;
        height: calc(100vh - 55px);
    }
}

/* Para tablets en landscape */
@media (max-width: 1024px) and (orientation: landscape) {
    .header {
        min-height: 55px;
    }
    
    .header h1 {
        font-size: 16px;
    }
}

/* ==================== */
/* SIDEBAR MEJORADO PARA MÓVILES */
/* ==================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 999;
        transition: transform 0.3s ease-in-out;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        left: 0;
    }
    
    .sidebar.active + .sidebar-overlay {
        display: block;
    }
    
    /* Asegurar que el contenido no se desborde */
    .content {
        width: 100%;
    }
}

/* ==================== */
/* ESTILOS EXISTENTES (se mantienen igual) */
/* ==================== */

/* Container principal */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar responsivo */
.sidebar {
    background-color: var(--color-secondary);
    color: var(--color-white);
    padding: 0;
    width: 250px;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar a {
    display: block;
    color: var(--color-white);
    padding: 1rem;
    text-decoration: none;
    border-bottom: 1px solid var(--color-accent);
    transition: background-color 0.3s ease;
}

.sidebar a:hover {
    background-color: var(--color-primary);
}

/* Content principal */
.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.content-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Botones responsivos */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    margin: 0.25rem;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--color-primary-dark);
}

.btn-secondary {
    background-color: #6c757d;
    color: var(--color-white);
}

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

.btn-success {
    background-color: var(--color-success);
    color: var(--color-white);
}

.btn-danger {
    background-color: var(--color-danger);
    color: var(--color-white);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Formularios responsivos */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* Cards responsivas */
.card {
    background-color: var(--color-white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

/* Tablas responsivas */
.table-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

/* Header fijo para la tabla */
.sticky-header {
    position: sticky;
    top: 0;
    background: #005CAB;
    color: white;
    z-index: 10;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

table, th, td {
    border: 1px solid #ddd;
}

.table-container {
    flex: 1;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    min-height: 300px;
}

/* Tabla con scroll interno */
.scrollable-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.scrollable-table th,
.scrollable-table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid #ddd;
    white-space: nowrap;
}

.scrollable-table th {
    background: var(--color-primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

th, td {
    padding: 0.75rem;
    text-align: left;
}

th {
    background-color: var(--color-primary);
    color: var(--color-white);
}

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

/* Stats cards responsivas */
.stats-section {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--color-white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--color-primary);
    margin: 0.5rem 0;
}

/* Export options responsivas */
.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.export-card {
    background-color: var(--color-white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* Mensajes */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Login responsivo */
.login-container {
    background-color: var(--color-white);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    margin: 2rem auto;
}

/* Media Queries generales */
@media (min-width: 768px) {
    .container {
        flex-direction: row;
        height: calc(100vh - 70px);
        margin-top: 0;
    }
    
    .sidebar {
        width: 250px;
        min-width: 250px;
        height: 100%;
        overflow-y: auto;
        position: sticky;
        top: 70px;
        order: 1;
        flex-shrink: 0;
        transform: none;
        left: 0;
    }
    
    .content {
        order: 2;
        flex: 1;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
}

@media (min-width: 1024px) {
    .content {
        padding: 2rem;
    }
    
    .stats-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .login-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .export-options {
        grid-template-columns: 1fr;
    }
}

/* Utilidades */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.hidden {
    display: none;
}

.visible {
    display: block;
}


/* Mensaje de error */
.error-message {
    display: none;
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    padding: 4px 8px;
    background-color: #fff5f5;
    border-radius: 4px;
    border-left: 3px solid #dc3545;
}

.error-message.show {
    display: block;
    animation: shake 0.3s ease-in-out;
}

/* Animaciones */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.uppercase-only.valid {
    animation: pulse 0.5s ease;
}

/* Tooltip para máximo de caracteres */
.character-count {
    position: absolute;
    right: 10px;
    top: 40px;
    font-size: 11px;
    color: #666;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    display: none;
}

.uppercase-only:focus + .character-count {
    display: block;
}


.dni-result {
    margin-top: 10px;
    padding: 10px;
    border-radius: 5px;
    background-color: #f8f9fa;
    border-left: 4px solid #007bff;
}

.dni-result.found {
    border-left-color: #28a745;
    background-color: #e8f5e9;
}

.dni-result.not-found {
    border-left-color: #dc3545;
    background-color: #fdecea;
}

.dni-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.dni-info-item {
    font-size: 13px;
}

.dni-info-label {
    font-weight: bold;
    color: #555;
}

.dni-info-value {
    color: #333;
}

.suggest-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 5px;
}

.suggest-button:hover {
    background-color: #0056b3;
}