/* ADD Plus Services ERP - Estilos globales */

:root {
    --sidebar-bg: #1a2035;
    --sidebar-hover: #252f4a;
    --sidebar-active: #3b82f6;
    --header-bg: #ffffff;
    --body-bg: #f0f2f5;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --primary: #3b82f6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
}

html, body {
    height: 100%;
    overflow: hidden; /* evita doble scroll */
}

body {
    background: var(--body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.925rem;
}

/* ======= SIDEBAR ======= */
#sidebar {
    width: 260px;
    height: 100vh;          /* fijo a la altura de la pantalla */
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

#sidebar .sidebar-logo {
    padding: 1.4rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

#sidebar .sidebar-logo .logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

#sidebar .sidebar-logo .logo-sub {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.45);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#sidebar .sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

#sidebar nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

#sidebar nav .nav-section {
    padding: 0.5rem 1.5rem 0.25rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    font-weight: 600;
}

#sidebar nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 0;
    transition: all 0.2s;
    font-size: 0.88rem;
    font-weight: 500;
    gap: 0.75rem;
    margin: 1px 0.5rem;
    border-radius: 8px;
}

#sidebar nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

#sidebar nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
}

#sidebar nav .nav-link .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

#sidebar .sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

#sidebar .sidebar-footer .user-info {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

#sidebar .sidebar-footer .user-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
}

/* ======= MAIN CONTENT ======= */
#main-content {
    margin-left: 260px;
    height: 100vh;          /* ocupa toda la pantalla */
    overflow-y: auto;       /* scroll solo en el contenido */
    display: flex;
    flex-direction: column;
}

/* ======= HEADER ======= */
#top-header {
    background: var(--header-bg);
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
}

#top-header .page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
}

#top-header .user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#top-header .user-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ======= KPI CARDS ======= */
.kpi-card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-icon.blue   { background: #eff6ff; color: #3b82f6; }
.kpi-icon.green  { background: #f0fdf4; color: #22c55e; }
.kpi-icon.orange { background: #fffbeb; color: #f59e0b; }
.kpi-icon.red    { background: #fef2f2; color: #ef4444; }
.kpi-icon.cyan   { background: #ecfeff; color: #06b6d4; }

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: #1f2937;
    line-height: 1;
}

.kpi-label {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
    margin-top: 0.15rem;
}

/* ======= CARDS ======= */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 0 0 !important;
    font-weight: 700;
    color: #1f2937;
    font-size: 0.95rem;
}

/* ======= TABLES ======= */
.table thead th {
    background: #f9fafb;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
    padding: 0.75rem 1rem;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.table-hover tbody tr:hover {
    background: #f9fafb;
}

/* ======= BADGES ======= */
.badge-estado {
    font-size: 0.72rem;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Prospecto estados */
.estado-nuevo          { background: #f3f4f6; color: #374151; }
.estado-contactado     { background: #eff6ff; color: #1d4ed8; }
.estado-calificado     { background: #f0fdf4; color: #15803d; }
.estado-en-cotizacion  { background: #fffbeb; color: #b45309; }
.estado-en-riesgo      { background: #fef2f2; color: #b91c1c; }
.estado-aprobado       { background: #d1fae5; color: #065f46; }
.estado-perdido        { background: #f1f5f9; color: #64748b; }
.estado-cliente        { background: #dbeafe; color: #1e40af; }

/* Cotización estados */
.estado-borrador        { background: #f3f4f6; color: #374151; }
.estado-enviada         { background: #eff6ff; color: #1d4ed8; }
.estado-en-revision     { background: #fffbeb; color: #b45309; }
.estado-aprobada        { background: #d1fae5; color: #065f46; }
.estado-rechazada       { background: #fef2f2; color: #b91c1c; }
.estado-expirada        { background: #f1f5f9; color: #64748b; }

/* Activo estados */
.estado-por-adquirir    { background: #f3f4f6; color: #374151; }
.estado-adquirido       { background: #eff6ff; color: #1d4ed8; }
.estado-en-instalacion  { background: #fffbeb; color: #b45309; }
.estado-instalado       { background: #ecfdf5; color: #065f46; }
.estado-activo          { background: #d1fae5; color: #065f46; }
.estado-en-mantenimiento{ background: #fef3c7; color: #92400e; }
.estado-incidencia      { background: #fef2f2; color: #b91c1c; }
.estado-terminado       { background: #f1f5f9; color: #64748b; }

/* Cobranza estados */
.estado-al-corriente    { background: #d1fae5; color: #065f46; }
.estado-proximo         { background: #fffbeb; color: #b45309; }
.estado-vencido         { background: #fef2f2; color: #b91c1c; }
.estado-gestion         { background: #eff6ff; color: #1d4ed8; }
.estado-convenio        { background: #f0f9ff; color: #0369a1; }
.estado-incumplimiento  { background: #fff1f2; color: #9f1239; }
.estado-pagado          { background: #f0fdf4; color: #15803d; }

/* ======= FORMS ======= */
.form-label {
    font-weight: 600;
    font-size: 0.83rem;
    color: #374151;
    margin-bottom: 0.3rem;
}

.form-control, .form-select {
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* ======= BUTTONS ======= */
.btn {
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 8px;
    padding: 0.5rem 1rem;
}

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

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* ======= PIPELINE ======= */
.pipeline-stage {
    background: #fff;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    text-align: center;
    box-shadow: var(--card-shadow);
    position: relative;
}

.pipeline-stage .stage-count {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1f2937;
}

.pipeline-stage .stage-name {
    font-size: 0.72rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pipeline-bar {
    height: 4px;
    border-radius: 2px;
    margin-top: 0.5rem;
}

/* ======= ALERTS ======= */
.alert-card {
    border-left: 4px solid;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    background: #fff;
    box-shadow: var(--card-shadow);
    margin-bottom: 0.75rem;
}

.alert-card.danger  { border-color: var(--danger); }
.alert-card.warning { border-color: var(--warning); }
.alert-card.info    { border-color: var(--info); }

/* ======= LOGIN ======= */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2035 0%, #2d3a5c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
}

/* ======= RESPONSIVE ======= */
@media (max-width: 992px) {
    #sidebar {
        transform: translateX(-260px);
    }

    #sidebar.open {
        transform: translateX(0);
    }

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

    .toggle-sidebar {
        display: block !important;
    }
}

.toggle-sidebar {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #374151;
    cursor: pointer;
    padding: 0.25rem;
}

/* Overlay para mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* ======= MISC ======= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1f2937;
    margin: 0;
}

.text-muted-sm {
    font-size: 0.8rem;
    color: #9ca3af;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.tab-pills .nav-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
}

.tab-pills .nav-link.active {
    background: var(--primary);
    color: #fff;
}

.bitacora-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.85rem;
}

.bitacora-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 0.4rem;
    flex-shrink: 0;
}
