/**
 * demos/gestion/css/style.css
 * Estilos SaaS & Dashboard para Nexus Cloud ERP/CRM
 * Desarrollado por AER Multinet
 */

:root {
    --erp-primary: #4f46e5;         /* Índigo corporativo */
    --erp-primary-hover: #4338ca;
    --erp-primary-light: #eef2ff;
    
    --erp-dark: #0f172a;            /* Slate oscuro para sidebar */
    --erp-dark-hover: #1e293b;
    --erp-sidebar-text: #94a3b8;
    
    --erp-bg: #f8fafc;              /* Fondo general de aplicación */
    --erp-card-bg: #ffffff;
    --erp-border: #e2e8f0;
    --erp-text: #1e293b;
    --erp-muted: #64748b;
    
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;

    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.nexus-body {
    font-family: var(--font-main);
    background-color: var(--erp-bg);
    color: var(--erp-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Barra Superior AER Multinet (Control de Demo) */
.aer-demo-topbar {
    background: #0b1329;
    color: #e2e8f0;
    font-size: 0.8125rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.aer-demo-topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.5rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.aer-demo-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.aer-demo-pulse {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: aerPulse 2s infinite;
}

@keyframes aerPulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.aer-demo-sep { color: #475569; }
.aer-demo-label { color: #94a3b8; }

.aer-demo-topbar-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.aer-demo-btn {
    padding: 0.35rem 0.8rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.aer-demo-btn-back {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.aer-demo-btn-back:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.aer-demo-btn-quote {
    background: #0284c7;
    color: #ffffff;
    border: 1px solid #0284c7;
}

.aer-demo-btn-quote:hover { background: #0369a1; }

/* ============================================================
   ESTRUCTURA GENERAL DEL LAYOUT (SIDEBAR + MAIN AREA)
============================================================ */
.nexus-layout-wrapper {
    display: flex;
    min-height: calc(100vh - 42px);
    position: relative;
}

/* Sidebar */
.nexus-sidebar {
    width: var(--sidebar-width);
    background-color: var(--erp-dark);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid #1e293b;
    z-index: 500;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--topbar-height);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon-box {
    width: 36px;
    height: 36px;
    background: var(--erp-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: #fff;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
    display: block;
    line-height: 1.2;
}

.brand-badge {
    font-size: 0.65rem;
    font-weight: 700;
    color: #818cf8;
    letter-spacing: 0.05em;
    display: block;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
}

.sidebar-menu-wrap {
    flex: 1;
    padding: 1.25rem 0.75rem;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0 0.75rem 0.5rem;
}

.sidebar-nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-nav-list .nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--erp-sidebar-text);
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.sidebar-nav-list .nav-link:hover {
    background-color: var(--erp-dark-hover);
    color: #ffffff;
}

.sidebar-nav-list .nav-item.active .nav-link {
    background-color: var(--erp-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.sidebar-user-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #090e1a;
}

.user-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #312e81;
    color: #a5b4fc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.user-info-text {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
}

.btn-user-action {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Área de contenido principal */
.nexus-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar de la aplicación */
.nexus-topbar {
    height: var(--topbar-height);
    background: var(--erp-card-bg);
    border-bottom: 1px solid var(--erp-border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 42px;
    z-index: 400;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    max-width: 480px;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--erp-border);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--erp-text);
    cursor: pointer;
    font-size: 1rem;
}

.topbar-search-box {
    position: relative;
    width: 100%;
}

.topbar-search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--erp-muted);
    font-size: 0.85rem;
}

.topbar-search-box input {
    width: 100%;
    background: var(--erp-bg);
    border: 1px solid var(--erp-border);
    border-radius: 20px;
    padding: 0.5rem 1rem 0.5rem 2.2rem;
    font-size: 0.85rem;
    font-family: var(--font-main);
    outline: none;
    transition: all 0.2s ease;
}

.topbar-search-box input:focus {
    background: #ffffff;
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.topbar-pill-demo {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(79, 70, 229, 0.08);
    color: var(--erp-primary);
    border: 1px solid rgba(79, 70, 229, 0.2);
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.live-pulse-dot {
    width: 6px;
    height: 6px;
    background: var(--erp-primary);
    border-radius: 50%;
    animation: liveBlink 1.5s infinite;
}

.topbar-icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--erp-bg);
    border: 1px solid var(--erp-border);
    color: var(--erp-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.topbar-icon-btn:hover {
    background: #ffffff;
    border-color: #cbd5e1;
}

.notif-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

.btn-topbar-quote {
    background: #25d366;
    color: #ffffff;
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s;
}

.btn-topbar-quote:hover {
    background: #1eb956;
}

/* Dropdown de Notificaciones */
.notif-dropdown {
    position: absolute;
    top: 110px;
    right: 24px;
    width: 320px;
    background: #ffffff;
    border: 1px solid var(--erp-border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 600;
    display: none;
    overflow: hidden;
}

.notif-dropdown.active {
    display: block;
}

.notif-dropdown-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notif-dropdown-header h4 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--erp-text);
}

.badge-new {
    background: var(--erp-primary-light);
    color: var(--erp-primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

.notif-list {
    max-height: 280px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--erp-border);
    font-size: 0.78rem;
}

.notif-item:hover {
    background: var(--erp-bg);
}

.notif-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.bg-success { background: var(--success-bg); color: var(--success); }
.bg-warning { background: var(--warning-bg); color: var(--warning); }
.bg-info { background: var(--info-bg); color: var(--info); }

.notif-time {
    display: block;
    color: var(--erp-muted);
    font-size: 0.7rem;
    margin-top: 2px;
}

/* ============================================================
   CONTENIDO INTERNO Y PANELES (DASHBOARD, TABLAS, FORMULARIOS)
============================================================ */
.nexus-content-body {
    flex: 1;
    padding: 1.75rem;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--erp-text);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--erp-muted);
    margin-top: 0.15rem;
}

.page-actions-group {
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

.btn-erp {
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: none;
    transition: all 0.2s ease;
}

.btn-erp-primary {
    background-color: var(--erp-primary);
    color: #ffffff;
}

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

.btn-erp-outline {
    background-color: #ffffff;
    border: 1px solid var(--erp-border);
    color: var(--erp-text);
}

.btn-erp-outline:hover {
    background-color: var(--erp-bg);
}

/* Grilla de Métricas KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background: var(--erp-card-bg);
    border: 1px solid var(--erp-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--erp-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--erp-text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.kpi-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.4rem;
}

.delta-pos { color: var(--success); }
.delta-neutral { color: var(--erp-muted); }

.kpi-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.icon-purple { background: #ede9fe; color: #7c3aed; }
.icon-emerald { background: #d1fae5; color: #059669; }
.icon-sky { background: #e0f2fe; color: #0284c7; }
.icon-amber { background: #fef3c7; color: #d97706; }

/* Gráficos y Tarjetas de Contenido */
.dashboard-grid-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
}

.chart-card {
    background: var(--erp-card-bg);
    border: 1px solid var(--erp-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.chart-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--erp-text);
}

/* Gráfico de Barras SVG */
.chart-bars-wrap {
    height: 220px;
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    padding-top: 1.5rem;
    border-bottom: 1px solid var(--erp-border);
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.bar-fill {
    width: 100%;
    max-width: 42px;
    background: linear-gradient(180deg, var(--erp-primary) 0%, #818cf8 100%);
    border-radius: 6px 6px 0 0;
    transition: height 0.5s ease;
    position: relative;
}

.bar-fill:hover {
    background: var(--erp-primary-hover);
}

.bar-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--erp-dark);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.bar-fill:hover .bar-tooltip {
    opacity: 1;
}

.bar-label {
    font-size: 0.75rem;
    color: var(--erp-muted);
    margin-top: 0.5rem;
    font-weight: 600;
}

/* Tablas Modernas SaaS */
.table-card {
    background: var(--erp-card-bg);
    border: 1px solid var(--erp-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-responsive-box {
    overflow-x: auto;
}

.erp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.erp-table th {
    background: var(--erp-bg);
    color: var(--erp-muted);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--erp-border);
}

.erp-table td {
    padding: 0.95rem 1.25rem;
    border-bottom: 1px solid var(--erp-border);
    color: var(--erp-text);
    vertical-align: middle;
}

.erp-table tr:hover td {
    background: #f8fafc;
}

/* Badges de Estado */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

.status-pill.status-completada,
.status-pill.status-activo,
.status-pill.status-en-stock {
    background: var(--success-bg);
    color: #047857;
}

.status-pill.status-pendiente,
.status-pill.status-stock-bajo {
    background: var(--warning-bg);
    color: #b45309;
}

.status-pill.status-en-proceso,
.status-pill.status-lead {
    background: var(--info-bg);
    color: #0369a1;
}

.status-pill.status-cancelada,
.status-pill.status-agotado,
.status-pill.status-inactivo {
    background: var(--danger-bg);
    color: #b91c1c;
}

/* Selectores de Cambio de Estado en Fila */
.select-status-interactive {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--erp-border);
    background: #ffffff;
    cursor: pointer;
    font-family: var(--font-main);
}

/* Modales Dinámicos */
.erp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.erp-modal-overlay.active {
    display: flex;
}

.erp-modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 540px;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.erp-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.erp-modal-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
}

.erp-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--erp-muted);
    cursor: pointer;
}

.erp-modal-body {
    padding: 1.5rem;
}

.erp-form-group {
    margin-bottom: 1.15rem;
}

.erp-form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--erp-text);
    margin-bottom: 0.35rem;
}

.erp-form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--erp-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font-main);
    outline: none;
}

.erp-form-control:focus {
    border-color: var(--erp-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.erp-modal-footer {
    padding: 1rem 1.5rem;
    background: var(--erp-bg);
    border-top: 1px solid var(--erp-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Pie del Sistema */
.nexus-footer {
    background: #ffffff;
    border-top: 1px solid var(--erp-border);
    padding: 1.75rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--erp-muted);
}

.footer-demo-disclaimer {
    max-width: 800px;
    margin: 0 auto;
}

.disclaimer-chip {
    display: inline-block;
    background: rgba(79, 70, 229, 0.1);
    color: var(--erp-primary);
    padding: 0.2rem 0.65rem;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.72rem;
    margin-bottom: 0.65rem;
}

.footer-links-row {
    margin-top: 0.85rem;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

/* ============================================================
   RESPONSIVE DESIGN (TABLET Y MÓVIL)
============================================================ */
@media (max-width: 1024px) {
    .dashboard-grid-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nexus-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
    }
    .nexus-sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-close-btn {
        display: block;
    }
    .sidebar-backdrop.active {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.6);
        z-index: 450;
    }
    .btn-sidebar-toggle {
        display: inline-flex;
    }
    .topbar-pill-demo {
        display: none;
    }
    .nexus-content-body {
        padding: 1rem;
    }
}
