/* =================================================================
   SalesForce Pro - Modern SaaS Theme (Stripe/Linear inspired)
   ================================================================= */

:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-success: #10b981;
    --color-success-light: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-danger: #ef4444;
    --color-danger-light: #fee2e2;
    --color-info: #06b6d4;
    --color-info-light: #cffafe;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    --sidebar-width: 248px;
    --topbar-height: 60px;
    --content-padding: 32px;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-gray-50);
    color: var(--color-gray-900);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}

.sidebar-brand-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--color-primary), #7c3aed);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px; font-weight: 700;
}

.sidebar-brand-text {
    font-size: 15px; font-weight: 600; color: var(--color-gray-900); letter-spacing: -0.01em;
}

.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}

.sidebar-user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-info));
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-weight: 600; font-size: 13px; color: var(--color-gray-900);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 12px; color: var(--color-gray-500); }

.sidebar-nav { flex: 1; padding: 12px 12px; overflow-y: auto; }

.sidebar-section-label {
    text-transform: uppercase; font-size: 11px; font-weight: 600;
    color: var(--color-gray-400); letter-spacing: 0.05em;
    padding: 12px 12px 6px 12px;
}

.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; color: var(--color-gray-700);
    text-decoration: none; border-radius: var(--radius);
    font-size: 13.5px; font-weight: 500;
    transition: all 0.15s ease; margin-bottom: 1px;
}

.sidebar-nav a:hover { background: var(--color-gray-100); color: var(--color-gray-900); }
.sidebar-nav a.active { background: var(--color-primary-light); color: var(--color-primary); }
.sidebar-nav a.active i { color: var(--color-primary); }
.sidebar-nav a i { width: 16px; color: var(--color-gray-500); font-size: 14px; text-align: center; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-color); }

/* MAIN */
.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    min-height: 100vh; display: flex; flex-direction: column;
}

.topbar {
    height: var(--topbar-height); background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--content-padding);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}

.topbar-search { position: relative; flex: 1; max-width: 420px; }
.topbar-search input {
    width: 100%; padding: 8px 12px 8px 36px;
    background: var(--color-gray-100); border: 1px solid transparent;
    border-radius: var(--radius); font-size: 13px;
}
.topbar-search input:focus {
    background: white; border-color: var(--color-gray-300);
    outline: none; box-shadow: 0 0 0 3px var(--color-primary-light);
}
.topbar-search i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--color-gray-400); font-size: 13px;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-action-btn {
    width: 36px; height: 36px; background: transparent; border: none;
    border-radius: var(--radius); color: var(--color-gray-600); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.topbar-action-btn:hover { background: var(--color-gray-100); }

.content-area {
    flex: 1; padding: var(--content-padding);
    max-width: 1400px; margin: 0 auto; width: 100%;
}

/* PAGE HEADER */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-title {
    font-size: 24px; font-weight: 700; color: var(--color-gray-900);
    margin: 0 0 4px 0; letter-spacing: -0.02em;
}
.page-subtitle { color: var(--color-gray-500); font-size: 14px; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* CARDS */
.card {
    background: white; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border-color);
    background: white; display: flex; align-items: center; justify-content: space-between;
}
.card-header h5, .card-header h4, .card-header h3 {
    font-size: 15px; font-weight: 600; color: var(--color-gray-900); margin: 0;
}
.card-body { padding: 20px; }

/* STAT CARDS */
.stat-card {
    background: white; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 20px;
    box-shadow: var(--shadow-sm); transition: all 0.2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-label { font-size: 13px; color: var(--color-gray-500); font-weight: 500; margin-bottom: 8px; }
.stat-card-value {
    font-size: 28px; font-weight: 700; color: var(--color-gray-900);
    line-height: 1.1; margin-bottom: 8px; letter-spacing: -0.02em;
}
.stat-card-icon {
    float: right; width: 40px; height: 40px;
    border-radius: var(--radius); display: flex;
    align-items: center; justify-content: center;
    font-size: 18px; margin-top: -4px;
}

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 14px; font-size: 13.5px; font-weight: 500; line-height: 1;
    border-radius: var(--radius); border: 1px solid transparent;
    cursor: pointer; transition: all 0.15s ease;
    text-decoration: none; white-space: nowrap;
}
.btn:focus { outline: none; box-shadow: 0 0 0 3px var(--color-primary-light); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: white; }
.btn-secondary { background: white; color: var(--color-gray-700); border-color: var(--color-gray-300); }
.btn-secondary:hover { background: var(--color-gray-50); color: var(--color-gray-900); }
.btn-success { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-success:hover { background: #059669; color: white; }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-outline-primary { color: var(--color-primary); border-color: var(--color-gray-300); background: white; }
.btn-outline-primary:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-outline-danger { color: var(--color-danger); border-color: var(--color-gray-300); background: white; }
.btn-outline-danger:hover { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-icon {
    width: 30px; height: 30px; padding: 0;
    background: transparent; border: 1px solid transparent;
    color: var(--color-gray-600); border-radius: var(--radius);
}
.btn-icon:hover { background: var(--color-gray-100); color: var(--color-gray-900); }
.btn-block { display: flex; width: 100%; }
.btn-link { background: transparent; border: none; padding: 4px; }

/* TABLES */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table thead th {
    background: var(--color-gray-50); border-bottom: 1px solid var(--border-color);
    text-align: left; padding: 11px 16px; font-weight: 600;
    color: var(--color-gray-600); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.table tbody td {
    padding: 12px 16px; border-bottom: 1px solid var(--color-gray-100);
    color: var(--color-gray-700); vertical-align: middle;
}
.table tbody tr:hover { background: var(--color-gray-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table tfoot th { background: var(--color-gray-50); padding: 12px 16px; font-weight: 600; }
.text-end, .text-right { text-align: right; }

/* FORMS */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--color-gray-700); margin-bottom: 6px;
}
.form-control {
    display: block; width: 100%; padding: 8px 12px;
    font-size: 14px; line-height: 1.5; color: var(--color-gray-900);
    background: white; border: 1px solid var(--color-gray-300);
    border-radius: var(--radius); transition: all 0.15s ease;
}
.form-control:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-control:read-only, .form-control[readonly] { background: var(--color-gray-50); }
.form-control-sm { padding: 5px 10px; font-size: 13px; }
textarea.form-control { min-height: 80px; }

.form-row {
    display: flex; flex-wrap: wrap;
    margin-right: -8px; margin-left: -8px;
}
.form-row > [class*="col-"] { padding: 0 8px; }

.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group-prepend { display: flex; }
.input-group-text {
    display: flex; align-items: center; padding: 8px 12px;
    background: var(--color-gray-100); border: 1px solid var(--color-gray-300);
    border-right: none; border-radius: var(--radius) 0 0 var(--radius);
    font-size: 13px; color: var(--color-gray-600); font-weight: 500;
}
.input-group .input-group-prepend + .form-control {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { margin: 0; }
.form-check-label { margin: 0; font-weight: 500; }
.form-text { font-size: 12px; color: var(--color-gray-500); margin-top: 4px; }
.form-actions { display: flex; gap: 8px; padding-top: 8px; }

/* BADGES */
.badge {
    display: inline-block; padding: 3px 8px; font-size: 11.5px;
    font-weight: 600; line-height: 1.2; text-transform: uppercase;
    letter-spacing: 0.03em; border-radius: var(--radius-sm);
}
.badge-lg { padding: 5px 10px; font-size: 12px; }
.badge-success { background: var(--color-success-light); color: #065f46; }
.badge-warning { background: var(--color-warning-light); color: #92400e; }
.badge-danger { background: var(--color-danger-light); color: #991b1b; }
.badge-info { background: var(--color-info-light); color: #155e75; }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-secondary { background: var(--color-gray-100); color: var(--color-gray-700); }

/* ALERTS */
.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 14px;
    display: flex; align-items: flex-start; gap: 10px;
    border: 1px solid transparent;
}
.alert-success { background: var(--color-success-light); color: #065f46; border-color: #a7f3d0; }
.alert-danger { background: var(--color-danger-light); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--color-info-light); color: #155e75; border-color: #a5f3fc; }
.alert-warning { background: var(--color-warning-light); color: #92400e; border-color: #fde68a; }
.alert-dismissible .close {
    background: transparent; border: 0; margin-left: auto;
    font-size: 20px; line-height: 1; color: inherit; opacity: 0.5; cursor: pointer;
}
.alert-dismissible .close:hover { opacity: 1; }

/* PROGRESS */
.progress { background: var(--color-gray-200); border-radius: 999px; overflow: hidden; height: 6px; }
.progress-bar { background: var(--color-primary); height: 100%; transition: width 0.3s ease; }
.progress-bar.bg-success { background: var(--color-success); }
.progress-bar.bg-warning { background: var(--color-warning); }
.progress-bar.bg-danger { background: var(--color-danger); }

/* DROPDOWN */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute; right: 0; top: 100%;
    background: white; border: 1px solid var(--border-color);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 180px; padding: 4px; margin-top: 4px;
    z-index: 1000; display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; color: var(--color-gray-700);
    text-decoration: none; border-radius: var(--radius-sm);
    font-size: 13.5px; cursor: pointer;
}
.dropdown-item:hover { background: var(--color-gray-100); color: var(--color-gray-900); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* TIMELINE */
.timeline { padding: 0; }
.timeline-item { padding: 10px 0; }
.timeline-icon { width: 24px; flex-shrink: 0; text-align: center; font-size: 16px; }

/* AUTH PAGES */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f3e8ff 100%);
    padding: 20px;
}
.auth-card {
    background: white; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
    padding: 40px 36px;
}
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; }
.auth-title {
    font-size: 20px; font-weight: 700; color: var(--color-gray-900);
    text-align: center; margin-bottom: 4px; letter-spacing: -0.02em;
}
.auth-subtitle { font-size: 13.5px; color: var(--color-gray-500); text-align: center; margin-bottom: 24px; }

/* GRID */
.row { display: flex; flex-wrap: wrap; margin-right: -12px; margin-left: -12px; }
.row > [class*="col-"] { padding: 0 12px; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-md-5 { flex: 0 0 41.666%; max-width: 41.666%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; }
.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-md-9 { flex: 0 0 75%; max-width: 75%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }
.col-sm-3 { flex: 0 0 25%; max-width: 25%; }
.col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-sm-6 { flex: 0 0 50%; max-width: 50%; }
.col-sm-8 { flex: 0 0 66.666%; max-width: 66.666%; }
.col-sm-9 { flex: 0 0 75%; max-width: 75%; }
.col-sm-12 { flex: 0 0 100%; max-width: 100%; }

/* UTILITIES */
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.ml-2 { margin-left: 8px; } .ml-3 { margin-left: 16px; }
.mr-1 { margin-right: 4px; } .mr-2 { margin-right: 8px; } .mr-3 { margin-right: 16px; }
.p-0 { padding: 0; } .p-2 { padding: 8px; } .p-3 { padding: 16px; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--color-gray-500); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-primary { color: var(--color-primary); }
.text-white { color: white; }
.bg-light { background: var(--color-gray-50); }
.bg-white { background: white; }
.bg-primary { background: var(--color-primary); }
.bg-success { background: var(--color-success); }
.bg-warning { background: var(--color-warning); }
.bg-danger { background: var(--color-danger); }
.d-flex { display: flex; }
.d-block { display: block; }
.d-none { display: none; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.flex-fill { flex: 1; }
.flex-column { flex-direction: column; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.align-items-center { align-items: center; }
.rounded { border-radius: var(--radius); }
.small { font-size: 12px; }
.h4 { font-size: 18px; font-weight: 600; }
.h5 { font-size: 16px; font-weight: 600; }

dl.row dt { font-weight: 600; color: var(--color-gray-700); margin-bottom: 4px; font-size: 13px; }
dl.row dd { margin-bottom: 12px; color: var(--color-gray-900); }

code {
    background: var(--color-gray-100); color: var(--color-gray-800);
    padding: 1px 6px; border-radius: var(--radius-sm);
    font-size: 12px; font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

hr { border: 0; border-top: 1px solid var(--border-color); margin: 16px 0; }

/* DataTables overrides */
.dataTables_wrapper { padding: 16px; }
.dataTables_filter input {
    padding: 6px 10px; border: 1px solid var(--color-gray-300);
    border-radius: var(--radius); font-size: 13px;
}
.dataTables_length select {
    padding: 4px 8px; border: 1px solid var(--color-gray-300);
    border-radius: var(--radius);
}
.paginate_button {
    padding: 5px 10px !important; margin: 0 2px !important;
    border: 1px solid var(--color-gray-300) !important; border-radius: var(--radius) !important;
    background: white !important; color: var(--color-gray-700) !important;
}
.paginate_button.current { background: var(--color-primary) !important; color: white !important; border-color: var(--color-primary) !important; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .col-md-3, .col-md-4, .col-md-6, .col-md-8 { flex: 0 0 100%; max-width: 100%; }
    .form-row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
    :root { --content-padding: 16px; }
}

/* KANBAN (CRM Pipeline) */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-column { flex: 0 0 280px; background: var(--color-gray-50); border-radius: var(--radius-md); padding: 12px; }
.kanban-column-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding: 0 4px;
}
.kanban-column-title { font-weight: 600; font-size: 13.5px; color: var(--color-gray-700); }
.kanban-column-count {
    background: var(--color-gray-200); color: var(--color-gray-700);
    font-size: 11px; font-weight: 600; padding: 2px 7px;
    border-radius: 999px;
}
.kanban-card {
    background: white; border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 12px;
    margin-bottom: 8px; cursor: pointer; transition: all 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card-title { font-weight: 600; font-size: 13px; color: var(--color-gray-900); margin-bottom: 4px; }
.kanban-card-meta { font-size: 12px; color: var(--color-gray-500); }
