﻿/* ============================================================
   SmartSales Intelligence  |  Light & Vibrant Design System
   ============================================================ */
:root {
    --bg-page:      #F0F2FF;
    --bg-card:      #FFFFFF;
    --bg-input:     #FAFBFF;

    /* Violet — brand intelligence */
    --violet:       #6D28D9;
    --violet-mid:   #7C3AED;
    --violet-soft:  #8B5CF6;
    --violet-light: #EDE9FE;
    --violet-dim:   rgba(109,40,217,0.07);

    /* Orange — sales energy */
    --orange:       #EA580C;
    --orange-mid:   #F97316;
    --orange-light: #FFF3EA;
    --orange-dim:   rgba(234,88,12,0.07);

    /* Status */
    --emerald:      #059669;
    --emerald-light:#ECFDF5;
    --sky:          #0284C7;
    --sky-light:    #E0F2FE;
    --rose:         #E11D48;
    --rose-light:   #FFF1F2;

    /* Text */
    --ink-0: #1E1B4B;
    --ink-1: #374151;
    --ink-2: #6B7280;
    --ink-3: #9CA3AF;
    --ink-4: #D1D5DB;

    /* Borders */
    --line-0: #E5E7EB;
    --line-v: #EDE9FE;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 20px rgba(30,27,75,.07), 0 1px 4px rgba(30,27,75,.04);
    --shadow-lg: 0 12px 40px rgba(30,27,75,.10), 0 2px 8px rgba(30,27,75,.04);
    --shadow-v:  0 4px 20px rgba(109,40,217,.22);
    --shadow-o:  0 4px 20px rgba(234,88,12,.22);

    /* Radius */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 24px;
}

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
    font-family: "Inter", "IBM Plex Sans Arabic", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: var(--ink-0);
    background-color: var(--bg-page);
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #F0F2FF; }
::-webkit-scrollbar-thumb { background: rgba(109,40,217,0.18); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(109,40,217,0.36); }

/* ── Typography ───────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.025em; color: var(--ink-0); margin-bottom: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 0.72rem; }
a, .btn-link { color: var(--violet); text-decoration: none; transition: color 130ms; }
a:hover { color: var(--violet-mid); }
h1:focus { outline: none; }

/* ── Welcome Banner ───────────────────────────────── */
.welcome-banner {
    background: linear-gradient(135deg, #6D28D9 0%, #7C3AED 50%, #9F67FA 100%);
    border-radius: var(--r-xl);
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-v);
}
.welcome-banner::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}
.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -60px; right: 60px;
    width: 140px; height: 140px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}
.welcome-banner h1 {
    color: #fff;
    font-size: 1.45rem;
    margin-bottom: 0.25rem;
    position: relative;
}
.welcome-banner p {
    color: rgba(255,255,255,0.72);
    margin: 0;
    font-size: 0.875rem;
    position: relative;
}

/* ── Page Header ──────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.6rem;
}
.page-header h1 { margin: 0; }
.page-header-icon {
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    background: var(--violet-light);
    border: 1px solid rgba(109,40,217,0.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--r-sm);
    padding: 0.5rem 1.2rem;
    transition: all 140ms ease;
    box-shadow: var(--shadow-xs);
}
.btn-primary {
    background: var(--violet);
    border-color: var(--violet);
    color: #fff;
    box-shadow: var(--shadow-v);
}
.btn-primary:hover {
    background: var(--violet-mid);
    border-color: var(--violet-mid);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(109,40,217,.32);
}
.btn-success {
    background: linear-gradient(135deg, #9A3412, #C2410C);
    border-color: #9A3412;
    color: #fff;
    font-weight: 700;
    box-shadow: var(--shadow-o);
}
.btn-success:hover {
    background: linear-gradient(135deg, #7C2D12, #9A3412);
    border-color: #7C2D12;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(234,88,12,.32);
}
.btn-outline-primary {
    color: var(--violet);
    border: 1.5px solid rgba(109,40,217,0.4);
    background: var(--violet-dim);
}
.btn-outline-primary:hover {
    background: var(--violet-light);
    border-color: var(--violet);
    color: var(--violet);
    transform: translateY(-1px);
}
.btn:focus, .btn:active:focus {
    box-shadow: 0 0 0 3px rgba(109,40,217,.22) !important;
    outline: none;
}

.btn-app {
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 0.5rem 1rem;
}

.btn-app-primary {
    background: linear-gradient(135deg, #6D28D9 0%, #7C3AED 65%, #8B5CF6 100%);
    color: #fff;
    border: 1px solid #6D28D9;
    box-shadow: 0 4px 16px rgba(109,40,217,0.25);
}

.btn-app-primary:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(109,40,217,0.32);
}

.btn-app-soft {
    background: #F6F5FF;
    color: #5B21B6;
    border: 1px solid #DDD6FE;
}

.btn-app-soft:hover {
    background: #EDE9FE;
    color: #4C1D95;
}

.btn-app-warn {
    background: #FFF4EE;
    color: #C2410C;
    border: 1px solid #FDBA74;
}

.btn-app-warn:hover {
    background: #FFEDD5;
    color: #9A3412;
}

/* ── Forms ────────────────────────────────────────── */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1.5px solid var(--line-0);
    border-radius: var(--r-sm);
    color: var(--ink-0);
    font-size: 0.9rem;
    transition: border-color 140ms, box-shadow 140ms;
}
.form-control:focus, .form-select:focus {
    background: #fff;
    border-color: var(--violet-soft);
    box-shadow: 0 0 0 3px rgba(109,40,217,.12);
    color: var(--ink-0);
    outline: none;
}
.form-control::placeholder { color: var(--ink-3); }
.form-select option { background: #fff; color: var(--ink-0); }
.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--ink-2);
    margin-bottom: 0.35rem;
}

/* ── Surface Card ─────────────────────────────────── */
.surface-card {
    background: var(--bg-card);
    border: 1px solid var(--line-0);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem 1.75rem;
    position: relative;
}
.surface-card h2 {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 1.1rem;
}
.surface-card h2::before {
    content: '';
    display: inline-block;
    width: 14px; height: 3px;
    background: linear-gradient(90deg, var(--violet), var(--orange-mid));
    border-radius: 99px;
    flex-shrink: 0;
}
.surface-card > p { color: var(--ink-1); margin-bottom: 0; }
.surface-card > ul { color: var(--ink-1); }

/* ── Metric Strip ─────────────────────────────────── */
.metric-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.3rem;
}
.metric-pill {
    border-radius: var(--r-lg);
    padding: 1.4rem 1.6rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.metric-pill:nth-child(1) {
    background: linear-gradient(135deg, #6D28D9 0%, #7C3AED 55%, #A78BFA 100%);
}
.metric-pill:nth-child(2) {
    background: linear-gradient(135deg, #EA580C 0%, #F97316 55%, #FB923C 100%);
}
.metric-pill:nth-child(3) {
    background: linear-gradient(135deg, #0891B2 0%, #06B6D4 55%, #22D3EE 100%);
}
.metric-pill:nth-child(4) {
    background: linear-gradient(135deg, #059669 0%, #10B981 55%, #34D399 100%);
}
.metric-pill::after {
    content: '';
    position: absolute;
    top: -24px; right: -24px;
    width: 110px; height: 110px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    pointer-events: none;
}
.metric-pill .label {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.72);
    margin-bottom: 0.5rem;
}
.metric-pill .value {
    font-size: 2.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #FFFFFF;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

/* ── Tables ───────────────────────────────────────── */
.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #FAFBFF;
    --bs-table-hover-bg: #F5F3FF;
    --bs-table-border-color: var(--line-0);
    color: var(--ink-1);
    margin-bottom: 0;
    font-size: 0.9rem;
}
.table thead th {
    background: #F9FAFB;
    color: var(--ink-3);
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line-0);
    padding: 0.8rem 1rem;
    white-space: nowrap;
}
.table td {
    vertical-align: middle;
    padding: 0.8rem 1rem;
    border-bottom-color: #F3F4F6;
}
.table tbody tr:last-child td { border-bottom: none; }
.table td:first-child { color: var(--ink-0); font-weight: 600; }

/* ── Utility ──────────────────────────────────────── */
.content { padding-top: 1rem; padding-bottom: 2.5rem; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--emerald); }
.invalid { outline: 1px solid var(--rose); }
.validation-message { color: var(--rose); font-size: 0.82rem; }

.blazor-error-boundary {
    background: var(--rose-light);
    border: 1px solid rgba(225,29,72,0.2);
    border-radius: var(--r-md);
    padding: 1rem 1rem 1rem 3.5rem;
    color: var(--rose);
}
.blazor-error-boundary::after { content: "An error has occurred." }

#blazor-error-ui {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line-0);
    box-shadow: 0 -4px 20px rgba(0,0,0,.07);
    bottom: 0; left: 0; right: 0;
    padding: 0.7rem 1.25rem;
    color: var(--rose);
    display: none;
    position: fixed;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ── Red Flag Strip ───────────────────────────────── */
.redflag-strip {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.redflag-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}
.redflag-high {
    background: #FFF1F2;
    border: 1px solid rgba(225,29,72,0.2);
    color: #9F1239;
}
.redflag-medium {
    background: #FFFBEB;
    border: 1px solid rgba(245,158,11,0.22);
    color: #92400E;
}
.redflag-low {
    background: var(--sky-light);
    border: 1px solid rgba(2,132,199,0.18);
    color: #075985;
}
.redflag-icon {
    font-size: 1.05rem;
    flex-shrink: 0;
}

/* ── Badge territory ──────────────────────────────── */
.badge-territory {
    display: inline-block;
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.18rem 0.55rem;
    border-radius: 99px;
    background: var(--violet-light);
    color: var(--violet);
    border: 1px solid rgba(109,40,217,0.18);
}

/* ── Commitment Archive Sidebar ───────────────────── */
.commitment-archive-sidebar {
    background: #fff;
    border-radius: var(--r-lg);
    border: 1.5px solid #EDE9FE;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.archive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, #6D28D9 0%, #7C3AED 100%);
    background: linear-gradient(135deg, #4C1D95 0%, #5B21B6 100%);
}
.archive-month-label {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.archive-nav-btn {
    background: rgba(255,255,255,0.24);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.archive-nav-btn:hover:not([disabled]) { background: rgba(255,255,255,0.4); }
.archive-nav-btn[disabled] { opacity: 0.35; cursor: default; }
.archive-empty {
    padding: 1.25rem 1rem;
    font-size: 0.85rem;
    color: #9CA3AF;
    text-align: center;
    margin: 0;
}
.archive-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    max-height: 520px;
    overflow-y: auto;
}
.archive-item {
    display: flex;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #F3F4F6;
}
.archive-item:last-child { border-bottom: none; }
.archive-check {
    color: #16A34A;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.archive-item-body { flex: 1; min-width: 0; }
.archive-item-customer {
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.archive-item-promise {
    font-size: 0.8rem;
    color: #6B7280;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.archive-item-date {
    font-size: 0.72rem;
    color: #9CA3AF;
    margin-top: 3px;
}

/* ── Notifications + Charts + Details ────────────── */
.notification-strip {
    display: grid;
    gap: 0.75rem;
}

.notification-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.9rem 1rem;
    border-radius: var(--r-md);
    border: 1px solid var(--line-0);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.notification-item strong {
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.notification-item span {
    color: var(--ink-2);
    font-size: 0.82rem;
}

.notification-medium {
    border-color: rgba(245, 158, 11, 0.22);
    background: #FFFBEB;
}

.notification-low {
    border-color: rgba(2, 132, 199, 0.16);
    background: #F0F9FF;
}

.mini-chart {
    display: flex;
    align-items: end;
    gap: 0.85rem;
    min-height: 150px;
}

.mini-chart-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    flex: 1;
}

.mini-chart-bar {
    width: 100%;
    max-width: 36px;
    border-radius: 12px 12px 4px 4px;
    background: linear-gradient(180deg, #8B5CF6 0%, #6D28D9 100%);
    box-shadow: var(--shadow-v);
}

.mini-chart-bar-wrap span {
    font-size: 0.72rem;
    color: var(--ink-2);
}

.customer-subtitle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ink-2);
    margin-top: 0.25rem;
}

.detail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.detail-list li {
    display: grid;
    gap: 0.2rem;
    padding: 0.85rem 0.95rem;
    border-radius: var(--r-md);
    background: #FAFBFF;
    border: 1px solid #EEF2FF;
}

.detail-list li span {
    color: var(--ink-1);
    font-size: 0.84rem;
}

.detail-list li small {
    color: var(--ink-3);
    font-size: 0.74rem;
}

.stage-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.stage-qualified {
    color: #1D4ED8;
    background: #DBEAFE;
}

.stage-proposal {
    color: #7C2D12;
    background: #FFEDD5;
}

.stage-negotiation {
    color: #6D28D9;
    background: #EDE9FE;
}

.stage-won {
    color: #166534;
    background: #DCFCE7;
}

.stage-lost {
    color: #9F1239;
    background: #FFE4E6;
}

.stage-positive {
    color: #166534;
    background: #DCFCE7;
}

.stage-neutral {
    color: #92400E;
    background: #FEF3C7;
}

.stage-negative {
    color: #9F1239;
    background: #FFE4E6;
}

[data-theme="dark"] {
    --bg-page: #0F172A;
    --bg-card: #111827;
    --bg-input: #0B1220;
    --ink-0: #F8FAFC;
    --ink-1: #CBD5E1;
    --ink-2: #94A3B8;
    --ink-3: #64748B;
    --line-0: #1E293B;
    --line-v: #312E81;
    --shadow-md: 0 8px 30px rgba(2, 6, 23, .45);
}

[data-theme="dark"] .surface-card,
[data-theme="dark"] .commitment-archive-sidebar,
[data-theme="dark"] .notification-item,
[data-theme="dark"] .detail-list li {
    background: #111827;
    border-color: #1F2937;
}

[data-theme="dark"] .top-row,
[data-theme="dark"] .sidebar {
    background: rgba(15, 23, 42, 0.96);
    border-color: #1F2937;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #0B1220;
    border-color: #243042;
    color: #F8FAFC;
}

[dir="rtl"] .page-header,
[dir="rtl"] .customer-subtitle,
[dir="rtl"] .top-breadcrumb,
[dir="rtl"] .top-right {
    direction: rtl;
}
