/* css/style.css - Estilos globales mejorados */
:root {
    --bg: #0f1724;
    --panel: #0b1220;
    --card: #0f1728;
    --accent: #2ecc71;
    --accent-hover: #27ae60;
    --muted: #98a0af;
    --glass: rgba(255,255,255,0.03);
    --glass-2: rgba(255,255,255,0.02);
    --white: #fff;
    --radius: 12px;
    --shadow: 0 6px 18px rgba(2,6,23,0.6);
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #2ecc71;
    --info: #3498db;
    --purple: #9b59b6;
    
    /* Nuevas variables para mejor organización */
    --text-primary: #ffffff;
    --text-secondary: #98a0af;
    --border-light: rgba(255,255,255,0.06);
    --border-medium: rgba(255,255,255,0.1);
    
    /* Variables para responsive */
    --header-height: 60px;
    --sidebar-width: 280px;
    --container-max-width: 1200px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, #061026 0%, #091428 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 18px;
    font-size: 14px;
    min-height: 100vh;
    line-height: 1.5;
}

/* ==================== LAYOUT GLOBAL ==================== */
.wrap {
    min-height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

/* ==================== HEADER GLOBAL ==================== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass);
    padding: 10px 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    min-width: min-content;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--success));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #02301a;
    font-size: 1.2rem;
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.brand .text-muted {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ==================== BOTONES GLOBALES ==================== */
.btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #02301a;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    min-height: 44px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background: linear-gradient(135deg, var(--accent-hover), #219652);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn.ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn.ghost:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--border-medium);
    transform: translateY(-1px);
}

.btn.danger {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    color: white;
}

.btn.danger:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn.warning {
    background: linear-gradient(135deg, var(--warning), #e67e22);
    color: white;
}

.btn:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:disabled::before {
    display: none;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 16px;
    min-height: 52px;
}

/* ==================== FORMULARIOS GLOBALES ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--card);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
    min-height: 44px;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
    background: var(--panel);
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* ==================== ALERTAS GLOBALES ==================== */
.alert {
    padding: 15px;
    border-radius: var(--radius);
    margin: 15px 0;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid transparent;
    line-height: 1.4;
}

.alert i {
    font-size: 1.1em;
    margin-top: 1px;
    flex-shrink: 0;
}

.alert-warning {
    background: rgba(231, 76, 60, 0.08);
    border-color: rgba(231, 76, 60, 0.3);
    color: var(--danger);
}

.alert-success {
    background: rgba(46, 204, 113, 0.08);
    border-color: rgba(46, 204, 113, 0.3);
    color: var(--success);
}

.alert-info {
    background: rgba(52, 152, 219, 0.08);
    border-color: rgba(52, 152, 219, 0.3);
    color: var(--info);
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    border-color: rgba(231, 76, 60, 0.4);
    color: var(--danger);
}

/* ==================== MODALES GLOBALES ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 25px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    color: var(--accent);
    font-size: 1.3rem;
    font-weight: 700;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

/* ==================== TABLAS GLOBALES ==================== */
.table-container {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
}

.table th,
.table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    background: var(--panel);
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table tbody tr {
    transition: background 0.3s ease;
}

.table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ==================== GRID SYSTEM ==================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col {
    flex: 1;
    padding: 0 10px;
    min-width: 0;
}

.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* ==================== CARDS GLOBALES ==================== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.card-header {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 700;
    color: var(--accent);
}

.card-body {
    padding: 0;
}

/* ==================== UTILIDADES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }

.p-0 { padding: 0; }
.p-1 { padding: 10px; }
.p-2 { padding: 20px; }
.p-3 { padding: 30px; }

.d-flex { display: flex; }
.d-none { display: none; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    body {
        padding: 12px;
        font-size: 13px;
    }
    
    .app-header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .brand {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    
    .col, .col-3, .col-4, .col-6, .col-8 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 15px;
    }
    
    .row {
        margin: 0 -8px;
    }
    
    .col {
        padding: 0 8px;
    }
    
    .modal-content {
        width: 100%;
        margin: 10px;
        padding: 20px;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .table {
        min-width: 600px;
    }
    
    .btn {
        min-height: 48px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .modal-content {
        padding: 15px;
        margin: 5px;
    }
    
    .form-control {
        padding: 14px 12px;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    .alert {
        padding: 12px;
        font-size: 13px;
    }
    
    .card {
        padding: 15px;
    }
}

/* ==================== MEJORAS DE ACCESIBILIDAD ==================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Enfoque visible para navegación con teclado */
button:focus-visible,
a:focus-visible,
.form-control:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Mejor contraste para modo alto contraste */
@media (prefers-contrast: high) {
    :root {
        --border-light: rgba(255,255,255,0.2);
        --glass: rgba(255,255,255,0.1);
    }
}

/* Soporte para modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0f1a;
        --panel: #070b14;
        --card: #0a101f;
    }
}

/* Variables para altura viewport móvil */
:root {
    --vh: 1vh;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--panel);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}