/* ============================================================
   SOY MARKETING — Sistema de diseño principal
   
   Paleta:
     --bg-deep:    #080b14    (fondo principal)
     --bg-surface: #0d1220    (tarjetas, paneles)
     --bg-raised:  #131a2c    (elementos elevados)
     --accent:     #6366f1    (indigo — acción principal)
     --accent-2:   #10b981    (esmeralda — éxito)
     --accent-3:   #f59e0b    (ámbar — advertencia)
     --accent-4:   #ef4444    (rojo — error)
     --accent-5:   #ec4899    (rosa — decorativo)
     --text:       #f0f2f8
     --text-dim:   rgba(255,255,255,0.55)
   
   Tipografía:
     Display: Orbitron (branding, títulos de sección)
     Body/UI: Inter (lectura, formularios, datos)
============================================================ */

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-deep:    #080b14;
    --bg-surface: #0d1220;
    --bg-raised:  #131a2c;
    --border:     rgba(255,255,255,0.07);
    --border-h:   rgba(255,255,255,0.15);
    --accent:     #6366f1;
    --accent-2:   #10b981;
    --accent-3:   #f59e0b;
    --accent-4:   #ef4444;
    --accent-5:   #ec4899;
    --text:       #f0f2f8;
    --text-dim:   rgba(255,255,255,0.55);
    --text-muted: rgba(255,255,255,0.35);
    --radius:     12px;
    --radius-sm:  8px;
    --radius-lg:  16px;
    --shadow:     0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg:  0 12px 48px rgba(0,0,0,0.55);
    --transition: 0.25s cubic-bezier(.22,1,.36,1);
    --sidebar-w:  240px;
}

html { height: 100%; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

/* ============================================================
   SIDEBAR
============================================================ */

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    min-height: 68px;
}

.sidebar-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.sidebar-logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, var(--accent), var(--accent-5));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Navegación ── */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    transition: all var(--transition);
    position: relative;
}

.nav-item .material-symbols-outlined {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

.nav-item.active {
    background: rgba(99,102,241,0.12);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

/* ── Footer del sidebar ── */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.25rem;
}

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-5));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.nav-logout {
    color: var(--accent-4) !important;
    opacity: 0.7;
}
.nav-logout:hover {
    opacity: 1;
    background: rgba(239,68,68,0.08) !important;
}

/* ============================================================
   MAIN CONTENT
============================================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    position: sticky;
    top: 0;
    height: 56px;
    background: rgba(8,11,20,0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 50;
}

.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

.topbar-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-user {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* ── Page content ── */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================================
   COMPONENTES REUTILIZABLES
============================================================ */

/* ── Tarjetas ── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-h);
    box-shadow: var(--shadow);
}

/* ── Grid de métricas (KPI cards) ── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all var(--transition);
}

.kpi-card:hover {
    border-color: var(--border-h);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.kpi-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon img {
    width: 24px; height: 24px;
    object-fit: contain;
}

.kpi-icon.indigo  { background: rgba(99,102,241,0.12); }
.kpi-icon.emerald { background: rgba(16,185,129,0.12); }
.kpi-icon.amber   { background: rgba(245,158,11,0.12); }
.kpi-icon.rose    { background: rgba(236,72,153,0.12); }
.kpi-icon.red     { background: rgba(239,68,68,0.12); }
.kpi-icon.sky     { background: rgba(56,189,248,0.12); }

.kpi-body { flex: 1; min-width: 0; }

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
}

.kpi-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── Botones ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #5558e6; }
.btn-primary:active { background: #4f4fdc; transform: scale(0.98); }

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--border-h); }

.btn-danger {
    background: rgba(239,68,68,0.12);
    color: var(--accent-4);
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.72rem; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }

/* ── Formularios ── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.4)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

/* ── Tablas ── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table thead th {
    background: var(--bg-raised);
    padding: 0.7rem 0.65rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table tbody td {
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-weight: 500;
    color: var(--text);
}

.data-table tbody tr:hover {
    background: rgba(99,102,241,0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Alertas ── */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.2);
    color: #6ee7b7;
}

.alert-warning {
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.2);
    color: #fcd34d;
}

.alert-info {
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    color: #a5b4fc;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-indigo  { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.badge-emerald { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.badge-amber   { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge-red     { background: rgba(239,68,68,0.15);  color: #fca5a5; }
.badge-rose    { background: rgba(236,72,153,0.15); color: #f9a8d4; }

/* ── Panel section ── */
.section-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.section-panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.section-panel-header img {
    width: 28px; height: 28px;
    object-fit: contain;
}

.section-panel-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.section-panel-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 600;
    background: var(--bg-raised);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
}

.section-panel-body {
    padding: 1.25rem;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-dim);
}

.empty-state .material-symbols-outlined {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.page-header p {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ── Iframe containers (Zoho) ── */
.iframe-container {
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    min-height: 600px;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ============================================================
   OVERLAY MÓVIL
============================================================ */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

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

@media (max-width: 768px) {
    :root { --sidebar-w: 260px; }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar-menu-btn {
        display: flex;
    }

    .page-content {
        padding: 1rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 0.75rem;
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================================
   SCROLLBAR
============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   ANIMACIONES
============================================================ */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* ── Loading spinner ── */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--text-dim);
    font-size: 0.82rem;
}
