/* ============================================================
   Revenue Governance System (RGS) — X86 Network
   Main Stylesheet
   ============================================================ */

:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --accent: #00c6ff;
    --sidebar-bg: #0f1b2d;
    --sidebar-hover: #1a2d4a;
    --sidebar-active: rgba(13, 110, 253, 0.25);
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --text-muted: #8a9bb0;
    --card-bg: #fff;
    --body-bg: #f0f4fa;
    --border-color: #e2e8f0;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    font-family: 'Inter', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--body-bg); color: #1e293b; font-family: 'Inter', sans-serif; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    z-index: 1040;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #0d6efd, #00c6ff);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}
.brand-name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub  { font-size: 10px; color: var(--text-muted); letter-spacing: .5px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 12px 10px 20px; }
.nav-section {
    font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
    color: var(--text-muted); text-transform: uppercase;
    padding: 14px 8px 4px; margin-top: 4px;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    color: #b0bec5;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: 14px; }
.sidebar-nav .nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: var(--accent); }

/* ---- Main Wrapper ---- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: linear-gradient(90deg, #0d6efd, #0a3d9e);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    position: sticky; top: 0; z-index: 1030;
}
.topbar-title { color: #fff; font-weight: 600; font-size: 15px; }
.topbar .btn-link { color: #fff !important; font-size: 18px; }
.topbar .dropdown-toggle { text-decoration: none; font-size: 13.5px; }
.sidebar-toggle { display: none; }

/* ---- Content Area ---- */
.content-area {
    flex: 1;
    padding: 24px;
}

/* ---- Footer ---- */
.app-footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 14px 24px;
    font-size: 12.5px;
    color: #64748b;
}

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.card-header {
    border-bottom: 1px solid var(--border-color);
    padding: 14px 18px;
    font-weight: 600;
    background: transparent;
    border-radius: 12px 12px 0 0 !important;
}

/* ---- KPI Stat Cards ---- */
.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    border: 1px solid var(--border-color);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.teal   { background: #ccfbf1; color: #0f766e; }
.stat-label { font-size: 12.5px; color: #64748b; font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; color: #1e293b; line-height: 1.2; }
.stat-sub   { font-size: 12px; color: #94a3b8; margin-top: 2px; }

/* ---- Tables ---- */
.table { font-size: 13.5px; }
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .3px;
    color: #4a5568;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
    padding: 10px 14px;
}
.table td { padding: 10px 14px; vertical-align: middle; border-color: var(--border-color); }
.table tbody tr:hover { background: #f8fafc; }

/* ---- Badges ---- */
.badge { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 20px; }
.bg-role-admin   { background: #7c3aed !important; }
.bg-role-manager { background: #0369a1 !important; }
.bg-role-sales   { background: #047857 !important; }
.bg-role-ops     { background: #b45309 !important; }
.bg-role-finance { background: #dc2626 !important; }

/* ---- Buttons ---- */
.btn { border-radius: 8px; font-size: 13px; font-weight: 500; }
.btn-primary { background: linear-gradient(135deg, #0d6efd, #0a58ca); border: none; }
.btn-primary:hover { background: linear-gradient(135deg, #0a58ca, #083d9e); }

/* ---- Workflow Stage Indicator ---- */
.workflow-steps {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.workflow-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f1f5f9;
    border-radius: 0;
    font-size: 12.5px;
    font-weight: 500;
    color: #64748b;
    position: relative;
}
.workflow-step:first-child { border-radius: 8px 0 0 8px; }
.workflow-step:last-child  { border-radius: 0 8px 8px 0; }
.workflow-step.done    { background: #dcfce7; color: #166534; }
.workflow-step.active  { background: #dbeafe; color: #1e40af; font-weight: 700; }
.workflow-step.pending { background: #f1f5f9; color: #94a3b8; }

/* ---- Revenue Leakage Indicators ---- */
.leakage-alert { border-left: 4px solid #dc3545; }

/* ---- Margin display ---- */
.margin-good   { color: #16a34a; font-weight: 600; }
.margin-warn   { color: #d97706; font-weight: 600; }
.margin-danger { color: #dc2626; font-weight: 700; }

/* ---- Forms ---- */
.form-label { font-size: 13px; font-weight: 500; color: #374151; }
.form-control, .form-select { font-size: 13.5px; border-radius: 8px; border-color: var(--border-color); }
.form-control:focus, .form-select:focus { border-color: #0d6efd; box-shadow: 0 0 0 3px rgba(13,110,253,.15); }

/* ---- Quotation builder: line items ---- */
.line-item-row { background: #f8fafc; border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.line-item-row .line-margin { font-size: 12px; font-weight: 600; }

/* ---- Section Divider ---- */
.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0 14px;
}
.section-divider span { font-size: 12px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.section-divider::before, .section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ---- Login page ---- */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1b2d 0%, #0d6efd 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-logo {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, #0d6efd, #00c6ff);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; color: #fff;
    margin: 0 auto 20px;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: #1e293b; margin: 0; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle { display: block !important; }
    .content-area { padding: 16px; }
    .stat-card { flex-direction: column; text-align: center; }
    .workflow-steps { flex-direction: column; }
    .workflow-step { border-radius: 8px !important; width: 100%; }
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
