/* ================================================================
   MK CRM - Global Stylesheet
   ================================================================
   Design system built with pure CSS (Flexbox + Grid).
   No frameworks. Supports Light & Dark themes via [data-theme].
   ================================================================ */

/* ----------------------------------------------------------------
   1. RESET & BASE
---------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14.5px;
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.25s ease, color 0.25s ease;
}

a {
    text-decoration: none;
    color: inherit;
}

ul, ol {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

img { max-width: 100%; display: block; }

/* ----------------------------------------------------------------
   2. CSS VARIABLES - LIGHT THEME (default)
---------------------------------------------------------------- */
:root {
    /* Brand */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --primary-rgb: 79, 70, 229;

    /* Status */
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --violet: #8b5cf6;
    --violet-light: #ede9fe;

    /* Backgrounds */
    --bg-body: #f4f5fa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-topbar: #ffffff;
    --bg-hover: #f8f9fc;
    --bg-input: #ffffff;
    --bg-code: #f1f2f6;

    /* Text */
    --text-primary: #1f2330;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Borders */
    --border-color: #e5e7eb;
    --border-light: #f0f1f5;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 72px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* ----------------------------------------------------------------
   3. CSS VARIABLES - DARK THEME
---------------------------------------------------------------- */
[data-theme="dark"] {
    --primary: #6366f1;
    --primary-dark: #818cf8;
    --primary-light: #1e1b3a;
    --primary-rgb: 99, 102, 241;

    --success: #34d399;
    --success-light: #0d2a20;
    --danger: #f87171;
    --danger-light: #3a1616;
    --warning: #fbbf24;
    --warning-light: #3a2c0a;
    --info: #60a5fa;
    --info-light: #122238;
    --violet: #a78bfa;
    --violet-light: #241a3d;

    --bg-body: #14161f;
    --bg-sidebar: #1a1d29;
    --bg-card: #1c1f2c;
    --bg-topbar: #1a1d29;
    --bg-hover: #23273a;
    --bg-input: #1f2230;
    --bg-code: #23273a;

    --text-primary: #e8eaf0;
    --text-secondary: #a1a8bd;
    --text-muted: #6b7280;
    --text-inverse: #14161f;

    --border-color: #2c3040;
    --border-light: #23263300;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ----------------------------------------------------------------
   4. SCROLLBAR
---------------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ----------------------------------------------------------------
   5. APP SHELL LAYOUT
---------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ----------------------------------------------------------------
   6. SIDEBAR
---------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

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

.brand-icon {
    font-size: 28px;
    background: var(--primary-light);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

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

.brand-text strong {
    font-size: 15.5px;
    color: var(--text-primary);
}

.brand-text small {
    color: var(--text-muted);
    font-size: 11px;
}

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

.nav-section {
    margin-bottom: 18px;
}

.nav-section-title {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

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

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

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

.theme-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s ease;
}

.theme-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Sidebar toggle (mobile hamburger) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 42px;
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: var(--shadow-md);
}

.sidebar-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 90;
}

/* ----------------------------------------------------------------
   7. MAIN WRAPPER / TOPBAR
---------------------------------------------------------------- */
.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

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

.topbar-titles h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 380px;
    display: flex;
    align-items: center;
}

.topbar-search input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.search-icon {
    position: absolute;
    left: 12px;
    font-size: 14px;
    opacity: 0.6;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ----------------------------------------------------------------
   8. FLASH MESSAGES
---------------------------------------------------------------- */
.flash-message {
    margin: 18px 28px 0;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.flash-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.flash-error   { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.flash-warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning); }
.flash-info    { background: var(--info-light); color: var(--info); border: 1px solid var(--info); }

.flash-text { flex: 1; }

.flash-close {
    font-size: 18px;
    line-height: 1;
    opacity: 0.6;
    color: inherit;
}

.flash-close:hover { opacity: 1; }

/* ----------------------------------------------------------------
   9. PAGE CONTENT / FOOTER
---------------------------------------------------------------- */
.page-content {
    padding: 24px 28px 40px;
    flex: 1;
}

.app-footer {
    padding: 16px 28px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

/* ----------------------------------------------------------------
   10. BUTTONS
---------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.92); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(0.92); }

.btn-outline { background: transparent; border-color: var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-hover); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ----------------------------------------------------------------
   11. FORMS
---------------------------------------------------------------- */
.form-group {
    margin-bottom: 18px;
}

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

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

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 5px;
}

.form-error {
    font-size: 11.5px;
    color: var(--danger);
    margin-top: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-control.is-invalid { border-color: var(--danger); }

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2394a3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

fieldset.form-fieldset {
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 20px;
}

fieldset.form-fieldset legend {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    padding: 0 8px;
}

/* ----------------------------------------------------------------
   12. CARDS
---------------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header h2, .card-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.card-body {
    padding: 22px;
}

.card-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border-color);
}

/* Stat Cards (Dashboard) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-light); color: var(--danger); }
.stat-icon.info    { background: var(--info-light); color: var(--info); }
.stat-icon.violet  { background: var(--violet-light); color: var(--violet); }

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

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

/* Generic content grid (2-column dashboard sections etc.) */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ----------------------------------------------------------------
   13. TABLES
---------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.data-table thead th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-hover);
    white-space: nowrap;
}

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

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

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

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

.table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cell-primary { font-weight: 600; color: var(--text-primary); }
.cell-secondary { color: var(--text-secondary); font-size: 12.5px; }

/* ----------------------------------------------------------------
   14. BADGES
---------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

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

.badge-pending    { background: var(--warning-light); color: var(--warning); }
.badge-messaged   { background: var(--info-light); color: var(--info); }
.badge-interested { background: var(--violet-light); color: var(--violet); }
.badge-customer   { background: var(--success-light); color: var(--success); }
.badge-blocked    { background: var(--danger-light); color: var(--danger); }
.badge-neutral    { background: var(--bg-hover); color: var(--text-secondary); }

/* ----------------------------------------------------------------
   15. PAGINATION
---------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 0 10px;
}

.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ----------------------------------------------------------------
   16. MODALS
---------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 26, 0.55);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.2s ease;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-body {
    padding: 22px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ----------------------------------------------------------------
   17. TIMELINE / ACTIVITY LIST
---------------------------------------------------------------- */
.timeline-list {
    position: relative;
    padding-left: 26px;
}

.timeline-list::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-color);
}

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

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 2px solid var(--primary);
}

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

.timeline-action {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-primary);
}

.timeline-details {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.timeline-time {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ----------------------------------------------------------------
   18. LIST ITEMS (Followups, Recent Contacts, etc.)
---------------------------------------------------------------- */
.list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.list-item-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.list-item-body { flex: 1; min-width: 0; }

.list-item-title {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.list-item-meta {
    text-align: right;
    flex-shrink: 0;
}

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

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 14px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 18px;
}

/* ----------------------------------------------------------------
   20. UTILITIES
---------------------------------------------------------------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary-color { color: var(--primary); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.w-full { width: 100%; }

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
    border: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--bg-hover);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

code, .code-block {
    background: var(--bg-code);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12.5px;
}

pre.code-block {
    padding: 14px 16px;
    overflow-x: auto;
    line-height: 1.5;
}

/* Google Map Assisted Entry - Parse Preview Box */
.parse-preview {
    background: var(--primary-light);
    border: 1px dashed var(--primary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 14px;
}

.parse-preview-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.15);
}

.parse-preview-row:last-child { border-bottom: none; }

.parse-preview-label { color: var(--text-secondary); font-weight: 600; }
.parse-preview-value { color: var(--text-primary); font-weight: 500; text-align: right; }

/* Progress / Loading Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    border-radius: 99px;
    background: var(--bg-hover);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.3s ease;
}

/* ----------------------------------------------------------------
   21. RESPONSIVE BREAKPOINTS
---------------------------------------------------------------- */
@media (max-width: 1024px) {
    .content-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar-toggle { display: flex; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .topbar {
        padding: 14px 20px 14px 66px;
    }

    .page-content {
        padding: 20px 18px 32px;
    }

    .flash-message {
        margin: 16px 18px 0;
    }

    .topbar-search {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
    }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .topbar-actions .btn span:not(:first-child) { display: none; }
    .card-body { padding: 16px; }
    .modal-box { max-width: 100%; }
}

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

/* ----------------------------------------------------------------
   22. PRINT STYLES (for printable exports)
---------------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .app-footer, .sidebar-toggle, .table-actions, .btn {
        display: none !important;
    }
    .page-content { padding: 0; }
    body { background: #fff; }
}
