:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --secondary: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --sidebar-width: 250px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f1f5f9;
    color: #334155;
}

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-card .logo h2 {
    color: var(--primary);
    font-size: 1.6rem;
    font-weight: 700;
}

.login-card .logo p { color: #64748b; font-size: 0.9rem; }

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: #fff;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span { color: var(--secondary); }

.sidebar-nav { padding: 16px 0; }

.nav-section {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.07);
    border-left-color: var(--secondary);
}

.sidebar-nav a i { width: 18px; text-align: center; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h4 { font-size: 1.1rem; color: var(--dark); font-weight: 600; }

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #64748b;
}

.topbar .user-info a {
    color: var(--danger);
    text-decoration: none;
    font-weight: 500;
}

.page-content { padding: 28px; flex: 1; }

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    margin-bottom: 24px;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
}

.card-body { padding: 24px; }

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: #ede9fe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.cyan { background: #cffafe; color: var(--secondary); }

.stat-info h3 { font-size: 1.8rem; font-weight: 700; color: var(--dark); }
.stat-info p { font-size: 0.82rem; color: #64748b; margin-top: 2px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border: 1px solid currentColor;
}

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 6px; color: #475569; }
.form-control {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #334155;
    transition: border-color 0.2s;
    background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
select.form-control { cursor: pointer; }

/* Tables */
.table-responsive { overflow-x: auto; }
table.dataTable { width: 100% !important; border-collapse: collapse; }
table.dataTable thead th {
    background: #f8fafc;
    padding: 12px 16px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
table.dataTable tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    vertical-align: middle;
}
table.dataTable tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-new { background: #ede9fe; color: #6d28d9; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-notinterested { background: #fee2e2; color: #991b1b; }
.badge-followup { background: #cffafe; color: #155e75; }
.badge-closed { background: #d1fae5; color: #065f46; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* Alerts */
.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #e0f2fe; color: #0c4a6e; border: 1px solid #bae6fd; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h5 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #64748b; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Upload area */
.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: #f5f3ff;
}
.upload-area i { font-size: 2.5rem; color: #94a3b8; margin-bottom: 12px; }
.upload-area p { color: #64748b; font-size: 0.9rem; }

/* Checkbox */
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* DataTables overrides — see bottom of file for full override */

.select-all-row { background: #f8fafc; }
.bulk-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Employee / shared clean table ──────────────────────────── */
table.emp-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table.emp-tbl thead th {
    background: #f8fafc;
    padding: 11px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    text-align: left;
}

table.emp-tbl tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
    text-align: left;
}

table.emp-tbl tbody tr:last-child td { border-bottom: none; }
table.emp-tbl tbody tr:hover { background: #f8fafc; }

/* Cell helpers */
table.emp-tbl .cell-id   { color: #94a3b8; font-size: 0.8rem; }
table.emp-tbl .cell-name { font-weight: 500; }
table.emp-tbl .cell-mono { font-family: 'Courier New', monospace; letter-spacing: 0.5px; font-size: 0.85rem; }
table.emp-tbl .cell-date { color: #64748b; font-size: 0.82rem; white-space: nowrap; }

/* Empty state */
table.emp-tbl .empty-row {
    text-align: center;
    padding: 40px 16px;
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Highlighted row (from dashboard link) */
tr.highlight-row { background: #eff6ff !important; }
tr.highlight-row td { border-left: 3px solid var(--primary); }

/* DataTables wrapper spacing for emp table */
#myLeadsTable_wrapper .dataTables_filter,
#myLeadsTable_wrapper .dataTables_length { padding: 14px 16px 0; }
#myLeadsTable_wrapper .dataTables_info,
#myLeadsTable_wrapper .dataTables_paginate { padding: 12px 16px; }

/* ── DataTables clean override ───────────────────────────────── */
.dataTables_wrapper {
    font-size: 0.875rem;
    color: #334155;
}

/* Top controls: length + filter on same row */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 14px 20px 10px;
    display: inline-block;
}
.dataTables_wrapper .dataTables_length { float: left; }
.dataTables_wrapper .dataTables_filter { float: right; }
.dataTables_wrapper::after { content:''; display:table; clear:both; }

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    font-size: 0.82rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 0.82rem;
    color: #334155;
    outline: none;
    background: #fff;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

/* Bottom: info + pagination */
.dataTables_wrapper .dataTables_info {
    padding: 12px 20px;
    font-size: 0.8rem;
    color: #94a3b8;
    float: left;
    clear: both;
}
.dataTables_wrapper .dataTables_paginate {
    padding: 10px 20px;
    float: right;
    clear: none;
}

/* Pagination buttons */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-block;
    padding: 5px 11px;
    margin: 0 2px;
    border-radius: 7px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569 !important;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    font-weight: 600;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background: #f8fafc;
    border-color: #f1f5f9;
    color: #cbd5e1 !important;
    cursor: default;
}

/* Sorting arrows */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    cursor: pointer;
    padding-right: 26px;
    position: relative;
}
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #cbd5e1;
}
table.dataTable thead th.sorting::after       { content: '⇅'; }
table.dataTable thead th.sorting_asc::after   { content: '↑'; color: var(--primary); }
table.dataTable thead th.sorting_desc::after  { content: '↓'; color: var(--primary); }

/* Clear float after wrapper */
.dataTables_wrapper .dataTables_paginate::after,
.dataTables_wrapper .dataTables_info::after {
    content: '';
    display: table;
    clear: both;
}
div.dataTables_wrapper div.dataTables_paginate ul.pagination { margin: 0; }

/* Hide DB id column header (used only for sorting) */
#myLeadsTable th.dt-id-col { display: none; }
