/* Marketing Agency CRM - Match dashboard reference: dark sidebar, orange active, Noto Sans Arabic */
:root {
    --sidebar-bg: #242d45;
    --sidebar-text: #adb5bd;
    --sidebar-active-bg: #fd6a00;
    --sidebar-active-text: #fff;
    --main-bg: #f8f9fa;
    --card-bg: #fff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
    --card-radius: 0.5rem;
    --text-primary: #212529;
    --text-muted: #6c757d;
    --accent-orange: #fd6a00;
}

* { box-sizing: border-box; }

body {
    background: var(--main-bg);
    font-family: 'Noto Sans Arabic', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    margin: 0;
}

/* ---------- Sidebar: dark blue/indigo, rounded nav items, active = solid orange ---------- */
.sidebar {
    background: var(--sidebar-bg);
    height: 100vh;
    overflow-y: auto;
    width: 260px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sidebar .brand-icon {
    font-size: 1.75rem;
    color: var(--accent-orange);
}

.sidebar .brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.3;
}

.sidebar .brand-text { flex: 1; min-width: 0; }
.sidebar .brand-sub {
    color: var(--sidebar-text);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.sidebar .nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.sidebar .nav-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
}

.sidebar .nav-link.active i { color: inherit; }

.sidebar .nav-bottom {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar .nav-bottom .nav-link { border-radius: 0.5rem; }

/* RTL: sidebar on right */
[dir="rtl"] .sidebar { left: auto; right: 0; }
[dir="rtl"] .main-wrapper { margin-left: 0; margin-right: 260px; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; margin-right: 0 !important; }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    [dir="rtl"] .sidebar.show { transform: translateX(0); }
}

/* ---------- Main wrapper & content ---------- */
.main-wrapper {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* ---------- Top bar: white, three zones (profile | notifications | search) ---------- */
.topbar {
    background: var(--card-bg);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

[dir="rtl"] .topbar { flex-direction: row-reverse; }

.topbar .topbar-menu-btn {
    color: var(--text-primary);
    text-decoration: none;
}
.topbar .topbar-menu-btn:hover { color: var(--sidebar-active-bg); }

.topbar .topbar-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar .profile-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.topbar .profile-name { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.topbar .profile-role { font-size: 0.8rem; color: var(--text-muted); }

.topbar .topbar-center {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar .btn-notif {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
    background: #fff;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar .btn-notif .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-orange);
}

[dir="rtl"] .topbar .btn-notif .badge-dot { right: auto; left: 6px; }

.topbar .search-wrap {
    position: relative;
    min-width: 220px;
    max-width: 320px;
}

.topbar .search-wrap input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

[dir="rtl"] .topbar .search-wrap input { padding: 0.5rem 0.75rem 0.5rem 2.5rem; }

.topbar .search-wrap .search-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

[dir="rtl"] .topbar .search-wrap .search-icon { right: auto; left: 0.75rem; }

/* ---------- Cards ---------- */
.card-dashboard {
    background: var(--card-bg);
    border: none;
    box-shadow: var(--card-shadow);
    border-radius: var(--card-radius);
}

.card-dashboard .card-header {
    background: var(--card-bg);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-dashboard .card-title { font-size: 1rem; margin: 0; }

/* ---------- KPI cards: icon (purple/yellow/green/blue), title, value, trend, period ---------- */
.kpi-card .card-body {
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

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

.kpi-card .kpi-icon.purple { background: rgba(102, 126, 234, 0.15); color: #667eea; }
.kpi-card .kpi-icon.yellow { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.kpi-card .kpi-icon.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.kpi-card .kpi-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }

.kpi-card .kpi-label { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.kpi-card .kpi-trend { font-size: 0.8rem; font-weight: 500; }
.kpi-card .kpi-period { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ---------- Activity list: timeline style, icon left, text + time ---------- */
.activity-list { list-style: none; padding: 0; margin: 0; }

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    align-items: flex-start;
}

.activity-item:last-child { border-bottom: none; }

.activity-item .activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.activity-item .activity-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.activity-item .activity-icon.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.activity-item .activity-icon.yellow { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.activity-item .activity-icon.gray { background: #f1f5f9; color: #64748b; }

.activity-item .activity-text { font-size: 0.9rem; }
.activity-item .activity-text .highlight { color: var(--accent-orange); font-weight: 500; }
.activity-item .activity-time { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

.link-view-all { color: var(--accent-orange); font-weight: 500; text-decoration: none; font-size: 0.9rem; }
.link-view-all:hover { color: #e55d00; }

/* ---------- Pipeline: horizontal bars, value on side, green for Closed ---------- */
.pipeline-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.pipeline-row .pipeline-label { min-width: 100px; font-size: 0.875rem; }
.pipeline-row .pipeline-bar-wrap { flex: 1; height: 28px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.pipeline-row .pipeline-bar { height: 100%; border-radius: 6px; min-width: 4px; transition: width 0.2s; }
.pipeline-row .pipeline-bar.orange { background: linear-gradient(90deg, #fed7aa, #fd6a00); }
.pipeline-row .pipeline-bar.green { background: #86efac; }
.pipeline-row .pipeline-value { font-size: 0.875rem; font-weight: 600; min-width: 2rem; text-align: left; }

[dir="rtl"] .pipeline-row .pipeline-value { text-align: right; }

/* ---------- Tasks table: status badges (blue/gray/green), avatar in assignee ---------- */
.tasks-table th { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.tasks-table .assignee-cell { display: flex; align-items: center; gap: 0.5rem; }
.tasks-table .assignee-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.badge-status { font-size: 0.75rem; font-weight: 500; padding: 0.25rem 0.5rem; border-radius: 0.35rem; }
.badge-status.pending { background: #e5e7eb; color: #4b5563; }
.badge-status.in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-status.review { background: #d1fae5; color: #047857; }
.badge-status.completed { background: #d1fae5; color: #047857; }

/* ---------- Modern Filter Bar ---------- */
.filter-bar {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.filter-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.filter-bar .filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-bar .form-control,
.filter-bar .form-select {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    padding: 0.45rem 0.75rem;
    background-color: #f9fafb;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-bar .form-control:focus,
.filter-bar .form-select:focus,
.form-control-modern:focus,
.form-select.form-control-modern:focus,
.card .form-control:focus,
.card .form-select:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(253, 106, 0, 0.1);
    background-color: #fff;
}

/* Form controls in cards (modern focus) */
.form-control-modern,
.form-select.form-control-modern {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

/* Nav tabs: active = accent orange */
.nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.6rem 1rem;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
}

.nav-tabs .nav-link.active {
    color: var(--accent-orange) !important;
    background: transparent !important;
    border-bottom-color: var(--accent-orange) !important;
}

.filter-bar .search-input-wrap {
    position: relative;
}

.filter-bar .search-input-wrap .form-control {
    padding-right: 2.25rem;
}

[dir="rtl"] .filter-bar .search-input-wrap .form-control {
    padding-right: 0.75rem;
    padding-left: 2.25rem;
}

.filter-bar .search-input-wrap .search-input-icon {
    position: absolute;
    top: 50%;
    right: 0.65rem;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.85rem;
    pointer-events: none;
}

[dir="rtl"] .filter-bar .search-input-wrap .search-input-icon {
    right: auto;
    left: 0.65rem;
}

.filter-bar .btn-filter {
    background: var(--accent-orange);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s, transform 0.1s;
    align-self: flex-end;
}

.filter-bar .btn-filter:hover {
    background: #e55d00;
    transform: translateY(-1px);
}

/* ---------- Modern Table ---------- */
.table-modern {
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern thead th {
    background: transparent;
    border-bottom: 2px solid #f1f5f9;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table-modern tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.table-modern tbody tr {
    transition: background 0.12s;
}

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

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

.table-modern a:not(.btn) {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s;
}

.table-modern a:not(.btn):hover {
    color: var(--accent-orange);
}

/* ---------- Modern Badges ---------- */
.badge-modern {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    line-height: 1.3;
}

.badge-modern.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-modern.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-modern.badge-green { background: #f0fdf4; color: #16a34a; }
.badge-modern.badge-red { background: #fef2f2; color: #dc2626; }
.badge-modern.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-modern.badge-orange { background: #fff7ed; color: #ea580c; }
.badge-modern.badge-purple { background: #faf5ff; color: #7c3aed; }

.badge-modern::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ---------- Action Buttons ---------- */
.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-size: 0.85rem;
    padding: 0;
}

.btn-action:hover {
    background: #f8fafc;
    color: var(--accent-orange);
    border-color: #d1d5db;
}

.btn-action.danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.btn-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

/* ---------- Empty State ---------- */
.table-empty-state {
    text-align: center;
    padding: 3rem 1rem !important;
}

.table-empty-state .empty-icon {
    font-size: 2.5rem;
    color: #d1d5db;
    margin-bottom: 0.75rem;
}

.table-empty-state .empty-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---------- Modern Pagination ---------- */
.pagination-modern .page-link {
    border: none;
    border-radius: 0.5rem !important;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    margin: 0 0.15rem;
    transition: all 0.15s;
}

.pagination-modern .page-link:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.pagination-modern .page-item.active .page-link {
    background: var(--accent-orange);
    color: #fff;
    box-shadow: 0 2px 6px rgba(253, 106, 0, 0.3);
}

.pagination-modern .page-item.disabled .page-link {
    background: transparent;
    color: #d1d5db;
}

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

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.page-header .header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.page-header .btn-add {
    background: var(--accent-orange);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
}

.page-header .btn-add:hover,
button.btn-add:hover {
    background: #e55d00;
    color: #fff;
    transform: translateY(-1px);
}

button.btn-add,
input[type="submit"].btn-add,
a.btn-add {
    background: var(--accent-orange);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background 0.15s, transform 0.1s;
    cursor: pointer;
    text-decoration: none;
}

.btn-add.w-100 { width: 100%; }

.page-header .btn-export {
    background: #f8fafc;
    color: var(--text-muted);
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s;
    text-decoration: none;
}

.page-header .btn-export:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

/* Pipeline Kanban */
.pipeline-kanban .pipeline-column {
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}
.pipeline-kanban .pipeline-column .card-header {
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}
.pipeline-kanban .pipeline-card {
    font-size: 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.4rem;
}
.pipeline-kanban .pipeline-cards {
    overflow-y: auto;
    max-height: 70vh;
}
