/**
 * MAYSAN IT CRM - Main Stylesheet (Arabic RTL)
 * IT & Security Solutions Branding
 * Color theme: Tech/Security (Deep teal + Cyber accent)
 */

:root {
    /* Brand colors - tech/security feel */
    --primary: #0f3a4f;          /* Deep teal-navy */
    --primary-light: #1e5a78;
    --primary-dark: #082633;
    --accent: #00d4aa;            /* Cyber green/teal accent */
    --accent-light: #4ee0c0;
    --secondary: #1e88e5;         /* Tech blue */

    /* Status colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --orange: #f97316;
    --cyan: #06b6d4;

    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --text-primary: #1f2937;
    --text-secondary: #4b5563;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --sidebar-width: 280px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    padding: 24px;
    transition: margin-right 0.3s;
}

@media (max-width: 991px) {
    .main-content {
        margin-right: 0;
        padding: 16px;
        padding-top: 70px;
    }
}

/* ============ MOBILE MENU TOGGLE ============ */
.mobile-menu-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: var(--shadow);
    font-size: 1.2rem;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

.sidebar-logo h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    letter-spacing: 0.5px;
}

.sidebar-logo span {
    font-size: 0.75rem;
    color: var(--accent);
    display: block;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 16px 0;
    flex: 1;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    padding: 0 12px 8px;
    font-weight: 600;
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s;
    font-size: 0.92rem;
    position: relative;
}

.nav-link i {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    color: rgba(255,255,255,0.6);
}

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

.nav-link:hover i {
    color: var(--accent);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(0, 212, 170, 0.2) 0%, rgba(0, 212, 170, 0.05) 100%);
    color: #fff;
    border-right: 3px solid var(--accent);
}

.nav-link.active i {
    color: var(--accent);
}

.nav-link .badge {
    margin-right: auto;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
}

.badge.red { background: var(--danger); }
.badge.yellow { background: var(--warning); }
.badge.blue { background: var(--info); }
.badge.green { background: var(--success); }
.badge.orange { background: var(--orange); }

/* User Info Card */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    font-weight: 600;
    color: #fff;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 0.75rem;
    color: var(--accent);
}

/* ============ PAGE HEADER ============ */
.page-header {
    background: white;
    padding: 22px 26px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    position: relative;
    overflow: hidden;
}
.page-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--accent), var(--secondary));
    opacity: 0.04;
    pointer-events: none;
}
.page-header > * { position: relative; z-index: 1; }

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.4rem;
}

.page-title i {
    color: var(--accent);
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 58, 79, 0.3);
    color: white;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #00b894 100%);
    color: white;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 212, 170, 0.3);
    color: white;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
    color: var(--gray-800);
}

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; color: white; }

.btn-outline {
    background: white;
    color: var(--primary);
    border: 1.5px solid var(--gray-300);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-icon {
    padding: 8px 10px;
}

/* ============ STATS CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Fixed-column variants — to avoid orphan cards in the last row */
.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1199px) {
    .stats-grid-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
    .stats-grid-4, .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .stats-grid-4, .stats-grid-3 { grid-template-columns: 1fr; }
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.stat-icon.primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
.stat-icon.accent { background: linear-gradient(135deg, var(--accent) 0%, #00b894 100%); }
.stat-icon.blue { background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%); }
.stat-icon.green { background: linear-gradient(135deg, var(--success) 0%, #059669 100%); }
.stat-icon.orange { background: linear-gradient(135deg, var(--orange) 0%, #ea580c 100%); }
.stat-icon.purple { background: linear-gradient(135deg, var(--purple) 0%, #7c3aed 100%); }
.stat-icon.red { background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%); }
.stat-icon.cyan { background: linear-gradient(135deg, var(--cyan) 0%, #0891b2 100%); }
.stat-icon.yellow { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); }
.stat-icon.pink { background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%); }
.stat-icon.gray { background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%); }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-top: 4px;
}

.stat-trend {
    font-size: 0.8rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============ CONTENT CARD ============ */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    overflow: hidden;
    margin-bottom: 20px;
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    background: linear-gradient(180deg, #fff 0%, var(--gray-50) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    font-size: 0.98rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    color: var(--accent);
    font-size: 0.95rem;
}

.card-body {
    padding: 20px;
}

/* Section/Stack of fields */
.section-divider {
    border-top: 1px dashed var(--gray-200);
    margin: 18px -20px;
}
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-label .required {
    color: var(--danger);
}

.form-control, .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.93rem;
    font-family: inherit;
    background: white;
    transition: all 0.15s;
    color: var(--gray-800);
}

.form-control::placeholder { color: var(--gray-400); }

.form-control:hover, .form-select:hover {
    border-color: var(--gray-300);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.12);
}

.form-control:disabled, .form-select:disabled {
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: not-allowed;
}

.form-control.form-select-sm, .form-select.form-select-sm {
    padding: 6px 10px;
    font-size: 0.82rem;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}

.checkbox-item:hover {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.05);
}

.checkbox-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"]:checked + label {
    color: var(--primary);
    font-weight: 600;
}

.checkbox-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    user-select: none;
}

/* ============ TABLES (UNIFIED STYLING) ============ */
.table-responsive {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    -webkit-overflow-scrolling: touch;
}

/* Tables inside cards - remove double styling */
.card-body > .table-responsive,
.card-body .data-table,
.card .table-responsive {
    box-shadow: none;
    border: none;
    border-radius: 0;
}
/* When a card-body wraps just a table, neutralize its padding */
.card-body:has(> .table-responsive),
.card-body:has(> .data-table) {
    padding: 0;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

/* Standalone data-table (not wrapped in table-responsive) */
.data-table:not(.table-responsive .data-table):not(.card .data-table) {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.data-table thead th {
    background: linear-gradient(180deg, var(--gray-50) 0%, #f3f4f6 100%);
    padding: 14px 16px;
    text-align: right;
    font-weight: 700;
    color: var(--gray-700);
    font-size: 0.82rem;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0.2px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table thead th:first-child { padding-right: 20px; }
.data-table thead th:last-child { padding-left: 20px; text-align: center; }

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
    vertical-align: middle;
    color: var(--gray-700);
}

.data-table tbody td:first-child { padding-right: 20px; }
.data-table tbody td:last-child { padding-left: 20px; text-align: center; }

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: rgba(0, 212, 170, 0.04);
}

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

.data-table a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}

.data-table a:hover {
    color: var(--accent);
}

/* Action buttons inside tables */
.data-table .btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

.data-table .btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
}

/* Column actions */
.data-table .col-actions {
    white-space: nowrap;
    text-align: center;
    width: 1%;
}

/* ============ STATUS BADGES (UNIFIED) ============ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.2;
    border: 1px solid transparent;
}

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

.status-blue { background: rgba(59, 130, 246, 0.10); color: #2563eb; border-color: rgba(59, 130, 246, 0.20); }
.status-cyan { background: rgba(6, 182, 212, 0.10); color: #0891b2; border-color: rgba(6, 182, 212, 0.20); }
.status-purple { background: rgba(139, 92, 246, 0.10); color: #7c3aed; border-color: rgba(139, 92, 246, 0.20); }
.status-orange { background: rgba(249, 115, 22, 0.10); color: #ea580c; border-color: rgba(249, 115, 22, 0.20); }
.status-yellow { background: rgba(245, 158, 11, 0.10); color: #b45309; border-color: rgba(245, 158, 11, 0.20); }
.status-pink { background: rgba(236, 72, 153, 0.10); color: #db2777; border-color: rgba(236, 72, 153, 0.20); }
.status-green { background: rgba(16, 185, 129, 0.10); color: #047857; border-color: rgba(16, 185, 129, 0.20); }
.status-red { background: rgba(239, 68, 68, 0.10); color: #b91c1c; border-color: rgba(239, 68, 68, 0.20); }
.status-gray { background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-200); }

/* Priority badges - same pill style */
.priority-low,
.priority-medium,
.priority-high,
.priority-urgent,
.priority-critical {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}
.priority-low::before, .priority-medium::before, .priority-high::before,
.priority-urgent::before, .priority-critical::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

.priority-low { background: rgba(16, 185, 129, 0.10); color: #047857; border-color: rgba(16, 185, 129, 0.20); }
.priority-medium { background: rgba(59, 130, 246, 0.10); color: #2563eb; border-color: rgba(59, 130, 246, 0.20); }
.priority-high { background: rgba(245, 158, 11, 0.10); color: #b45309; border-color: rgba(245, 158, 11, 0.20); }
.priority-urgent { background: rgba(239, 68, 68, 0.10); color: #b91c1c; border-color: rgba(239, 68, 68, 0.20); }
.priority-critical { background: var(--danger); color: white; }
.priority-critical::before { background: white; }

/* ============ FILTERS BAR ============ */
.filters-bar {
    background: white;
    padding: 16px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}
.filter-group .form-label {
    font-size: 0.78rem;
    color: var(--gray-600);
    margin-bottom: 4px;
}
.filter-group .form-control,
.filter-group .form-select {
    padding: 8px 12px;
    font-size: 0.88rem;
}

/* ============ ALERTS ============ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.alert-success { background: rgba(16, 185, 129, 0.1); color: #047857; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-danger { background: rgba(239, 68, 68, 0.1); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.2); }
.alert-info { background: rgba(59, 130, 246, 0.1); color: #1e40af; border: 1px solid rgba(59, 130, 246, 0.2); }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* ============ UTILS ============ */
.text-primary { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--gray-500) !important; }

.bg-primary-light { background: rgba(15, 58, 79, 0.05); }

.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.text-end { text-align: end; }
.text-center { text-align: center; }

/* ============ LOGIN PAGE ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(15, 58, 79, 0.95) 0%, rgba(8, 38, 51, 0.95) 100%),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(0,212,170,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo .logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    font-size: 2.4rem;
    border-radius: 20px;
}

.login-logo h1 {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.6rem;
    margin: 0;
    letter-spacing: 0.5px;
}

.login-logo p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ============ RESPONSIVE TABLE WRAPPER ============ */
@media (max-width: 768px) {
    .data-table thead {
        display: none;
    }

    .data-table tbody tr {
        display: block;
        background: white;
        margin-bottom: 12px;
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-sm);
        padding: 12px;
    }

    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid var(--gray-100);
    }

    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        margin-left: 12px;
    }

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

/* ============ MOBILE OVERLAY ============ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

@media (max-width: 991px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stat-value {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============ KANBAN BOARD ============ */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kanban-column {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 300px;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: white;
    font-weight: 700;
    color: var(--primary);
}

.kanban-column-count {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.kanban-card {
    background: white;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border-right: 3px solid var(--accent);
    cursor: pointer;
    transition: all 0.2s;
}

.kanban-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.kanban-card-title {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
    font-size: 0.92rem;
}

.kanban-card-meta {
    font-size: 0.78rem;
    color: var(--gray-500);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--gray-50); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
.sidebar::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ============ TOOLTIPS / HELPERS ============ */
.icon-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--gray-100);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--gray-600);
}
.icon-tag i { font-size: 0.7rem; }

.muted-link { color: var(--gray-500); font-size: 0.8rem; text-decoration: none; }
.muted-link:hover { color: var(--accent); }

.table-actions { display: flex; gap: 4px; justify-content: center; }
.table-actions .btn { padding: 6px 10px; font-size: 0.8rem; }

/* Skeleton loader (for future use) */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-200) 50%, var(--gray-100) 100%);
    background-size: 200% 100%;
    animation: skeleton-load 1.4s infinite ease-in-out;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-load { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Print-friendly */
@media print {
    .sidebar, .mobile-menu-toggle, .page-actions, .filters-bar { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .card, .table-responsive { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ============ CHART CONTAINER ============ */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}
.chart-container canvas {
    max-width: 100% !important;
}
@media (max-width: 768px) {
    .chart-container { height: 240px; }
}

/* ============ DARK MODE ============ */
body.dark {
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    background: #0b1220;
    color: var(--text-primary);
}
body.dark .page-header,
body.dark .card,
body.dark .stat-card,
body.dark .filters-bar,
body.dark .login-card,
body.dark .data-table,
body.dark .table-responsive {
    background: #0f1a2e;
    border-color: #1e293b;
    color: var(--text-primary);
}
body.dark .card-header {
    background: linear-gradient(180deg, #15233e 0%, #0f1a2e 100%);
    border-color: #1e293b;
}
body.dark .data-table thead th {
    background: linear-gradient(180deg, #15233e 0%, #0f1a2e 100%);
    color: var(--gray-700);
    border-color: #1e293b;
}
body.dark .data-table tbody td {
    color: var(--gray-700);
    border-color: #1e293b;
}
body.dark .data-table tbody tr:hover {
    background: rgba(0, 212, 170, 0.08);
}
body.dark .form-control,
body.dark .form-select {
    background: #15233e;
    border-color: #1e293b;
    color: var(--text-primary);
}
body.dark .form-control::placeholder { color: #64748b; }
body.dark .btn-secondary {
    background: #1e293b;
    color: #cbd5e1;
}
body.dark .btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: #334155;
}
body.dark .stat-value { color: var(--text-primary); }
body.dark .page-title { color: var(--text-primary); }
body.dark .card-title { color: var(--text-primary); }
body.dark .empty-state h3 { color: var(--text-primary); }
body.dark .alert-info { background: rgba(59,130,246,0.2); }
body.dark .alert-success { background: rgba(16,185,129,0.2); color: #6ee7b7; }
body.dark .alert-danger { background: rgba(239,68,68,0.2); color: #fca5a5; }
body.dark .alert-warning { background: rgba(245,158,11,0.2); color: #fbbf24; }

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    z-index: 200;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    font-size: 1.2rem;
    transition: transform 0.2s;
}
.theme-toggle:hover { transform: scale(1.1) rotate(15deg); }
body.dark .theme-toggle {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

/* ============ AVATAR / INITIAL CIRCLE ============ */
.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    margin-left: 6px;
}

/* ============ LAYOUT HELPERS ============ */
/* Force columns in a row to equal height */
.equal-height-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}
.equal-height-row > [class*="col-"] {
    display: flex;
    flex-direction: column;
}
.equal-height-row > [class*="col-"] > .card,
.equal-height-row > [class*="col-"] > .h-100 {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Card body that fills its parent (for charts) */
.card .card-body.chart-fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}
.card .card-body.chart-fill > .chart-container {
    width: 100%;
    flex: 1;
    position: relative;
}
.card .card-body.chart-fill > .chart-container > canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Override the card-body :has() rule when explicitly padded */
.card-body.padded { padding: 20px !important; }

/* Bootstrap-like utilities (in case Bootstrap CSS doesn't fully cover) */
.h-100 { height: 100%; }
.flex-grow-1 { flex-grow: 1; }
.flex-column { flex-direction: column; }
.d-flex { display: flex; }

/* Force the card itself to be a flex column when h-100 */
.card.h-100 {
    display: flex;
    flex-direction: column;
}
.card.h-100 > .card-body {
    flex: 1;
}