/* ============================================================
   Nivex CRM - Main Stylesheet
   Modern SaaS-style CRM/ERP System
   Arabic RTL - Responsive
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 65px;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1e293b;
    --light-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: var(--primary-color);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-weight: 800;
    font-size: 18px;
    color: var(--text-primary);
}

.brand-tagline {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 1px;
}

.sidebar-menu {
    flex: 1;
    padding: 12px 8px;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    font-size: 13.5px;
}

.sidebar-menu .nav-link i {
    width: 22px;
    text-align: center;
    font-size: 15px;
}

.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link.active {
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary-color);
}

.sidebar-menu .nav-link.active {
    font-weight: 600;
}

.sub-menu {
    padding-right: 20px;
    margin-top: 2px;
}

.sub-menu .nav-link {
    padding: 7px 14px;
    font-size: 13px;
    border-right: 2px solid transparent;
    border-radius: 0;
}

.sub-menu .nav-link:hover,
.sub-menu .nav-link.active {
    background: transparent;
    border-right-color: var(--primary-color);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/* ============================================================
   MAIN WRAPPER
   ============================================================ */

.main-wrapper {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */

.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */

.page-content {
    padding: 24px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: var(--card-bg);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 20px;
}

/* ============================================================
   STATS CARDS
   ============================================================ */

.stat-card {
    padding: 20px;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-icon.bg-primary-soft { background: rgba(79,70,229,0.1); color: var(--primary-color); }
.stat-icon.bg-success-soft { background: rgba(16,185,129,0.1); color: var(--success-color); }
.stat-icon.bg-warning-soft { background: rgba(245,158,11,0.1); color: var(--warning-color); }
.stat-icon.bg-danger-soft { background: rgba(239,68,68,0.1); color: var(--danger-color); }
.stat-icon.bg-info-soft { background: rgba(59,130,246,0.1); color: var(--info-color); }
.stat-icon.bg-secondary-soft { background: rgba(100,116,139,0.1); color: var(--secondary-color); }

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    font-weight: 600;
    font-size: 11px;
    padding: 5px 10px;
    border-radius: 20px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    font-weight: 600;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

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

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

/* ============================================================
   TABLES
   ============================================================ */

.table {
    font-size: 13px;
    margin-bottom: 0;
}

.table thead th {
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.02);
}

/* ============================================================
   FORMS
   ============================================================ */

.form-control, .form-select {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-family: 'Cairo', sans-serif;
}

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

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* ============================================================
   NOTIFICATIONS DROPDOWN
   ============================================================ */

.notification-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.notification-dropdown .dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

/* ============================================================
   KANBAN BOARD
   ============================================================ */

.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    background: var(--light-bg);
    border-radius: var(--radius-md);
    padding: 12px;
    flex-shrink: 0;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 4px;
}

.kanban-column-title {
    font-weight: 700;
    font-size: 13px;
}

.kanban-count {
    background: var(--card-bg);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.kanban-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    cursor: grab;
    transition: var(--transition);
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.kanban-card-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================================
   AUTH PAGES
   ============================================================ */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light-bg);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo i {
    font-size: 48px;
    color: var(--primary-color);
}

.auth-logo h2 {
    margin-top: 12px;
    font-weight: 800;
    font-size: 24px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 0;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
    display: none;
}

.mobile-overlay.active {
    display: block;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-right: 0;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .top-navbar {
        padding: 10px 16px;
    }
    
    .kanban-board {
        gap: 10px;
    }
    
    .kanban-column {
        min-width: 260px;
    }
}

@media (max-width: 575.98px) {
    .auth-card {
        padding: 24px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }

.avatar-sm {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state h5 {
    font-weight: 700;
    color: var(--text-primary);
}

.timeline {
    position: relative;
    padding-right: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 4px;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--card-bg);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.timeline-content {
    background: var(--light-bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* DataTables customization */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.dataTables_wrapper .dataTables_filter input {
    margin-right: 8px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    margin: 0 2px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    color: white !important;
    border: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
