/* ===== MarketFlow CRM - Main Stylesheet ===== */
:root {
    --sidebar-bg: #1a2035;
    --sidebar-hover: #252d45;
    --sidebar-active: #2563eb;
    --sidebar-text: #a0aec0;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', 'Cairo', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    direction: rtl;
    margin: 0;
    padding: 0;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-height: var(--topbar-height);
}

.sidebar-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
}

.sidebar-brand .brand-sub {
    color: var(--sidebar-text);
    font-size: 11px;
    font-weight: 400;
}

.sidebar-section {
    padding: 8px 0;
}

.sidebar-section-title {
    color: var(--sidebar-text);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 12px 20px 6px;
    opacity: 0.6;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
    cursor: pointer;
}

.sidebar-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.sidebar-item.active {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
    border-right-color: var(--sidebar-active);
}

.sidebar-item i {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

/* ===== Main Content ===== */
.main-wrapper {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.breadcrumb { margin: 0; font-size: 13px; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; color: var(--text-secondary); }

.topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--body-bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 15px;
}

.topbar-btn:hover { background: var(--border-color); color: var(--primary); }

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}

.notification-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Page Content ===== */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ===== Cards ===== */
.card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    background: var(--card-bg);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ===== Stat Cards ===== */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-primary);
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #10b981; }
.stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }
.stat-icon.pink { background: #fce7f3; color: #db2777; }
.stat-icon.yellow { background: #fef9c3; color: #ca8a04; }

.stat-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== Tables ===== */
.table-responsive { border-radius: 12px; overflow: hidden; }

.table {
    margin: 0;
    font-size: 14px;
}

.table thead th {
    background: var(--body-bg);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

/* ===== Badges ===== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-active { background: #d1fae5; color: #065f46; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-paused { background: #fef9c3; color: #854d0e; }
.badge-completed { background: #dbeafe; color: #1e40af; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-new { background: #ede9fe; color: #5b21b6; }
.badge-contacted { background: #fce7f3; color: #9d174d; }
.badge-interested { background: #d1fae5; color: #065f46; }
.badge-negotiation { background: #fed7aa; color: #9a3412; }
.badge-closed { background: #dbeafe; color: #1e40af; }
.badge-lost { background: #fee2e2; color: #991b1b; }
.badge-vip { background: #fef3c7; color: #92400e; }
.badge-ontrack { background: #d1fae5; color: #065f46; }
.badge-atrisk { background: #fef9c3; color: #854d0e; }
.badge-achieved { background: #dbeafe; color: #1e40af; }
.badge-missed { background: #fee2e2; color: #991b1b; }

/* ===== Forms ===== */
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.form-label {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 13.5px;
    padding: 8px 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== Progress Bar ===== */
.progress {
    height: 6px;
    border-radius: 10px;
    background: var(--border-color);
}

.progress-bar { border-radius: 10px; }

/* ===== KPI Progress ===== */
.kpi-card {
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.kpi-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
}

/* ===== Pipeline / Kanban ===== */
.pipeline-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.pipeline-column {
    min-width: 240px;
    max-width: 240px;
    background: var(--body-bg);
    border-radius: 12px;
    padding: 12px;
}

.pipeline-column-header {
    font-weight: 700;
    font-size: 13px;
    padding: 8px 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pipeline-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: box-shadow 0.2s;
    font-size: 13px;
}

.pipeline-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* ===== Alert Messages ===== */
.alert {
    border-radius: 10px;
    border: none;
    padding: 12px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Search & Filter Bar ===== */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* ===== Avatar ===== */
.avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2035 0%, #2d3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    margin-bottom: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-right: 0; }
    .pipeline-board { flex-direction: column; }
    .pipeline-column { min-width: 100%; max-width: 100%; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--body-bg); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== Chart container ===== */
.chart-container { position: relative; }
canvas { max-width: 100%; }

/* ===== Threat level indicator ===== */
.threat-1 { color: #10b981; }
.threat-2 { color: #84cc16; }
.threat-3 { color: #f59e0b; }
.threat-4 { color: #f97316; }
.threat-5 { color: #ef4444; }

/* ===== Print ===== */
@media print {
    .sidebar, .topbar { display: none !important; }
    .main-wrapper { margin-right: 0 !important; }
}
