/* ============================================================
   ITERIA VIA — Design System
   Tokens + Componentes base reutilizables
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    /* Brand Colors */
    --brand-navy: #0B192C;
    --brand-navy-light: #152A4A;
    --brand-navy-medium: #1F3D6B;
    --brand-cyan: #00E5FF;
    --brand-cyan-light: #67e8f9;
    --brand-cyan-dark: #00B4CC;
    --brand-purple: #651FFF;
    --brand-purple-light: #8E54E9;
    --brand-blue: #3b82f6;
    --brand-blue-light: #60a5fa;

    /* Neutral */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --shadow-glow-cyan: 0 0 20px rgba(34,211,238,0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--gray-200);
    background: var(--brand-navy);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-cyan); text-decoration: none; }
a:hover { color: var(--brand-cyan-light); }

img { max-width: 100%; display: block; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand-cyan-dark), var(--brand-cyan));
    color: var(--brand-navy);
}
.btn-primary:hover { box-shadow: var(--shadow-glow-cyan); transform: translateY(-1px); }

.btn-secondary {
    background: var(--brand-navy-light);
    color: var(--gray-300);
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover { background: var(--brand-navy-medium); color: #fff; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
    background: transparent;
    color: var(--gray-400);
}
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,0.05); }

.btn-outline {
    background: transparent;
    color: var(--brand-cyan);
    border: 1px solid var(--brand-cyan);
}
.btn-outline:hover { background: rgba(34,211,238,0.1); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-info    { background: rgba(59,130,246,0.15);  color: var(--info); }
.badge-neutral { background: rgba(148,163,184,0.15); color: var(--gray-400); }
.badge-cyan    { background: rgba(34,211,238,0.1);  color: var(--brand-cyan); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--brand-navy-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
}
.card:hover { border-color: rgba(255,255,255,0.1); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}
.card-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   INPUTS
   ============================================================ */
.form-group { margin-bottom: var(--space-md); }
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-400);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--brand-cyan);
    box-shadow: 0 0 0 3px rgba(34,211,238,0.1);
}
.form-input::placeholder { color: var(--gray-600); }
.form-select { cursor: pointer; }
.form-select option { background: var(--brand-navy); color: #fff; }
.form-textarea { min-height: 80px; resize: vertical; }

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.06);
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead th {
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    color: var(--gray-400);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.875rem;
}
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--brand-navy-light);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-normal);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.modal-header h3 { font-size: 1.1rem; color: #fff; }
.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.05);
    border: none; border-radius: var(--radius-sm);
    color: var(--gray-400); cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.modal-body { padding: var(--space-lg); }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-cyan { color: var(--brand-cyan) !important; }
.text-muted { color: var(--gray-500) !important; }
.text-sm { font-size: 0.8rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.3rem; }
.text-2xl { font-size: 1.6rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    /* Modal: full width on mobile */
    .modal {
        width: 96%;
        max-width: 96vw;
        max-height: 94vh;
        border-radius: var(--radius-lg);
    }
    .modal-body { padding: var(--space-md); }
    .modal-footer { 
        padding: var(--space-md); 
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-footer .btn { flex: 1; min-width: 100px; }
    .modal-header { padding: var(--space-md); }
    .modal-header h3 { font-size: 1rem; }

    /* Form inputs: bigger touch targets */
    .form-input, .form-select, .form-textarea {
        padding: 12px 14px;
        font-size: 16px; /* prevents iOS zoom */
    }

    /* Table responsive wrapper */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Pagination compact */
    .pagination { flex-wrap: wrap; }
    .pagination button { padding: 6px 8px; font-size: 0.75rem; }
}

@media (max-width: 480px) {
    .modal {
        width: 100%;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
}

/* ============================================================
   STAT CARD
   ============================================================ */
.stat-card {
    background: var(--brand-navy-light);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.08;
}
.stat-card.cyan::after  { background: var(--brand-cyan); }
.stat-card.green::after { background: var(--success); }
.stat-card.blue::after  { background: var(--brand-blue); }
.stat-card.amber::after { background: var(--warning); }

.stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}
.stat-sub {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 4px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--gray-500);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: var(--space-md); }
.empty-state p { font-size: 0.9rem; }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); color: var(--brand-navy); }
.toast-info    { background: var(--brand-blue); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--brand-cyan);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: var(--space-lg);
}
.pagination button {
    padding: 6px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    color: var(--gray-400);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.pagination button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.pagination button.active {
    background: var(--brand-cyan);
    color: var(--brand-navy);
    border-color: var(--brand-cyan);
    font-weight: 600;
}
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
