/* ==========================================
   EnlaceWifi Design System
   Paleta corporativa azul
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --ew-blue-900: #0a1628;
    --ew-blue-800: #0d2137;
    --ew-blue-700: #0f3460;
    --ew-blue-600: #1565c0;
    --ew-blue-500: #1976d2;
    --ew-blue-400: #42a5f5;
    --ew-blue-300: #90caf9;
    --ew-blue-100: #e3f2fd;
    --ew-accent: #00bcd4;
    --ew-sidebar-w: 260px;
    --ew-bg: #f0f4f8;
    --ew-card-border: #e8edf2;
    --ew-text: #1e293b;
    --ew-text-muted: #64748b;
    --ew-text-light: #94a3b8;
    --ew-success: #10b981;
    --ew-warning: #f59e0b;
    --ew-danger: #ef4444;
}

* { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
body { background: var(--ew-bg); margin: 0; min-height: 100vh; color: var(--ew-text); }

/* === SIDEBAR === */
.ew-sidebar {
    position: fixed; top: 0; left: 0; width: var(--ew-sidebar-w); height: 100vh;
    background: linear-gradient(180deg, var(--ew-blue-900) 0%, var(--ew-blue-700) 100%);
    color: white; z-index: 1000; display: flex; flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}
.ew-sidebar-brand {
    padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 12px; text-decoration: none; color: white;
}
.ew-sidebar-brand:hover { color: white; }
.ew-sidebar-brand .brand-icon {
    width: 42px; height: 42px; background: linear-gradient(135deg, var(--ew-blue-400), var(--ew-accent));
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 700; flex-shrink: 0;
}
.ew-sidebar-brand .brand-text { font-size: 1.1rem; font-weight: 600; line-height: 1.2; }
.ew-sidebar-brand .brand-sub { font-size: 0.7rem; color: var(--ew-blue-300); font-weight: 400; letter-spacing: 0.5px; }

.ew-sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.ew-sidebar-nav .nav-section {
    padding: 12px 20px 4px; font-size: 0.65rem; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--ew-blue-300); font-weight: 600;
}
.ew-sidebar-nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 20px;
    color: rgba(255,255,255,0.6); text-decoration: none; font-size: 0.88rem;
    font-weight: 400; transition: all 0.2s; border-left: 3px solid transparent; margin: 1px 0;
}
.ew-sidebar-nav a:hover { color: white; background: rgba(255,255,255,0.06); }
.ew-sidebar-nav a.active { color: white; background: rgba(255,255,255,0.1); border-left-color: var(--ew-accent); font-weight: 500; }
.ew-sidebar-nav a i { font-size: 1.1rem; width: 22px; text-align: center; }
.ew-sidebar-nav .nav-badge {
    font-size: 0.65rem; background: #ef5350; color: white; border-radius: 10px;
    padding: 1px 7px; margin-left: auto; font-weight: 600;
}

.ew-sidebar-user {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 10px;
}
.ew-sidebar-user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--ew-blue-400), var(--ew-accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem; flex-shrink: 0; color: white;
}
.ew-sidebar-user .user-info { flex: 1; min-width: 0; }
.ew-sidebar-user .user-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ew-sidebar-user .user-role { font-size: 0.7rem; color: var(--ew-blue-300); }

/* === MAIN LAYOUT === */
.ew-main { margin-left: var(--ew-sidebar-w); min-height: 100vh; }

/* === TOPBAR === */
.ew-topbar {
    background: white; padding: 16px 32px; border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
}
.ew-topbar h4 { margin: 0; font-weight: 600; color: var(--ew-blue-900); font-size: 1.2rem; }
.ew-topbar .topbar-sub { margin: 0; color: var(--ew-text-muted); font-size: 0.82rem; }
.ew-topbar-actions { display: flex; gap: 8px; align-items: center; }

/* === CONTENT === */
.ew-content { padding: 28px 32px; }

/* === CARDS === */
.ew-card {
    background: white; border-radius: 14px; border: 1px solid var(--ew-card-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04); overflow: hidden;
}
.ew-card-header {
    padding: 16px 20px; font-weight: 600; font-size: 0.9rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #f1f5f9;
}
.ew-card-body { padding: 20px; }
.ew-card-body.p-0 { padding: 0; }

/* === METRIC CARDS === */
.ew-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.ew-metric {
    background: white; border-radius: 14px; padding: 20px; position: relative; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04); border: 1px solid var(--ew-card-border); transition: all 0.25s;
}
.ew-metric:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.08); }
.ew-metric .metric-icon {
    width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center;
    justify-content: center; font-size: 1.4rem; margin-bottom: 14px;
}
.ew-metric .metric-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.ew-metric .metric-label { font-size: 0.8rem; color: var(--ew-text-muted); margin-top: 4px; font-weight: 500; }
.ew-metric .metric-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; }

/* === BUTTONS === */
.btn-ew { background: var(--ew-blue-600); color: white; border: none; border-radius: 8px; font-weight: 500; font-size: 0.88rem; }
.btn-ew:hover { background: var(--ew-blue-500); color: white; }
.btn-ew-outline { background: transparent; color: var(--ew-blue-600); border: 1.5px solid var(--ew-blue-600); border-radius: 8px; font-weight: 500; font-size: 0.88rem; }
.btn-ew-outline:hover { background: var(--ew-blue-100); color: var(--ew-blue-600); }

/* === TABLE === */
.ew-table { width: 100%; border-collapse: collapse; }
.ew-table thead th {
    background: #f8fafc; padding: 12px 16px; font-size: 0.78rem; font-weight: 600;
    color: var(--ew-text-muted); text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}
.ew-table tbody td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; font-size: 0.88rem; vertical-align: middle; }
.ew-table tbody tr { transition: background 0.15s; }
.ew-table tbody tr:hover { background: #f8fafc; }
.ew-table tbody tr.clickable { cursor: pointer; }

/* === BADGES === */
.ew-badge { font-size: 0.72rem; padding: 3px 10px; border-radius: 6px; font-weight: 600; display: inline-block; }
.ew-badge-soporte { background: #fff3e0; color: #e65100; }
.ew-badge-instalacion { background: var(--ew-blue-100); color: var(--ew-blue-600); }
.ew-badge-mantenimiento { background: #f1f5f9; color: #475569; }
.ew-badge-retiro { background: #fce4ec; color: #c62828; }
.ew-badge-cambio_domicilio { background: #f3e5f5; color: #6a1b9a; }

.ew-badge-nueva { background: #fef2f2; color: #dc2626; }
.ew-badge-en_validacion { background: #fffbeb; color: #d97706; }
.ew-badge-programada { background: var(--ew-blue-100); color: var(--ew-blue-600); }
.ew-badge-en_ruta { background: #e0f2fe; color: #0284c7; }
.ew-badge-en_sitio { background: #dbeafe; color: #1d4ed8; }
.ew-badge-finalizada_por_tecnico { background: #ecfdf5; color: #059669; }
.ew-badge-cerrada { background: #ecfdf5; color: #10b981; }
.ew-badge-reprogramar { background: #fffbeb; color: #d97706; }
.ew-badge-no_se_pudo { background: #f1f5f9; color: #475569; }

.ew-badge-baja { background: #f1f5f9; color: #64748b; }
.ew-badge-media { background: #fffbeb; color: #d97706; }
.ew-badge-alta { background: #fef2f2; color: #dc2626; }
.ew-badge-urgente { background: #fef2f2; color: #dc2626; font-weight: 700; }

/* === TABS === */
.ew-tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.ew-tab {
    padding: 12px 24px; font-weight: 600; font-size: 0.88rem; color: var(--ew-text-muted);
    text-decoration: none; border-bottom: 3px solid transparent; transition: all 0.2s;
    display: flex; align-items: center; gap: 6px;
}
.ew-tab:hover { color: var(--ew-text); border-bottom-color: #cbd5e1; }
.ew-tab.active { color: var(--ew-blue-600); border-bottom-color: var(--ew-blue-600); }
.ew-tab .tab-count {
    font-size: 0.7rem; background: #e2e8f0; color: var(--ew-text-muted);
    border-radius: 10px; padding: 1px 8px; font-weight: 600;
}
.ew-tab.active .tab-count { background: var(--ew-blue-600); color: white; }

/* === FILTER BAR === */
.ew-filters {
    background: white; padding: 16px 20px; border-radius: 12px; margin-bottom: 20px;
    border: 1px solid var(--ew-card-border);
}

/* === FORM SECTIONS === */
.ew-form-section {
    background: white; border-radius: 14px; padding: 24px; margin-bottom: 20px;
    border: 1px solid var(--ew-card-border); box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ew-form-section h5 {
    color: var(--ew-blue-600); margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 2px solid var(--ew-blue-100); font-size: 1rem; font-weight: 600;
}

/* === MOBILE TOGGLE === */
.ew-mobile-toggle {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 1100;
    width: 42px; height: 42px; border-radius: 12px; border: none;
    background: var(--ew-blue-600); color: white; font-size: 1.3rem;
    cursor: pointer; box-shadow: 0 4px 12px rgba(21,101,192,0.35);
    align-items: center; justify-content: center;
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ew-mobile-toggle:active { transform: scale(0.92); }
.ew-sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 999; opacity: 0; transition: opacity 0.3s;
}
.ew-sidebar-overlay.active { display: block; opacity: 1; }

/* === RESPONSIVE === */
@media (max-width: 992px) {
    .ew-sidebar { width: 220px; }
    .ew-main { margin-left: 220px; }
    .ew-content { padding: 20px; }
    .ew-topbar { padding: 14px 20px; }
}
@media (max-width: 768px) {
    .ew-mobile-toggle { display: flex; }
    .ew-sidebar {
        transform: translateX(-100%); transition: transform 0.3s ease;
        width: 270px;
    }
    .ew-sidebar.show { transform: translateX(0); }
    .ew-main { margin-left: 0; }
    .ew-content { padding: 16px; }
    .ew-topbar { padding: 12px 16px; padding-left: 62px; }
    .ew-metric-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .ew-table thead th { font-size: 0.72rem; padding: 10px 8px; }
    .ew-table tbody td { padding: 10px 8px; font-size: 0.82rem; }
}

/* === SIDEBAR SUBMENU === */
.ew-sidebar-nav a.nav-toggle .nav-arrow {
    margin-left: auto; font-size: 0.7rem; transition: transform 0.25s;
}
.ew-sidebar-nav a.nav-toggle.open .nav-arrow { transform: rotate(90deg); }
.ew-sidebar-nav .nav-submenu {
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
}
.ew-sidebar-nav .nav-submenu.open { max-height: 200px; }
.ew-sidebar-nav .nav-submenu a {
    padding: 8px 20px 8px 54px; font-size: 0.82rem; position: relative;
}
.ew-sidebar-nav .nav-submenu a::before {
    content: ''; position: absolute; left: 34px; top: 50%; transform: translateY(-50%);
    width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,0.3);
    transition: background 0.2s;
}
.ew-sidebar-nav .nav-submenu a:hover::before,
.ew-sidebar-nav .nav-submenu a.active::before { background: var(--ew-accent); }

/* === UTILITIES === */
.ew-section-title {
    font-size: 0.78rem; font-weight: 600; color: var(--ew-text-muted);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px;
}
.ew-link { color: var(--ew-blue-600); text-decoration: none; font-weight: 500; }
.ew-link:hover { color: var(--ew-blue-500); text-decoration: underline; }
