@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('./typography.css');
@import url('./components/modal.css');
@import url('./components/buttons.css');
@import url('./components/toast.css');

@import url('./components/forms.css');
@import url('./components/badges.css');
@import url('./components/tables.css');
@import url('./components/cards.css');
@import url('./layout/grid.css');

/* ═══════════════════════════════════════════════════════════════════════
   DESIGN TOKENS — Light Mode (Default)
════════════════════════════════════════════════════════════════════════ */
:root {
    /* Brand (overridden dynamically via header.php) */
    --primary-h: 221;
    --primary-s: 83%;
    --primary-l: 53%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-dark: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) - 8%));
    --primary-light: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.1);

    /* Semantic colors */
    --success: var(--color-success);
    --danger: var(--color-danger);
    --warning: var(--color-warning);
    --info: var(--color-info);

    /* Surface & Background */
    --background: var(--slate-50);
    --surface: #ffffff;
    --surface-2: var(--slate-100);
    --border: var(--slate-200);

    /* Text */
    --text: var(--slate-900);
    --text-muted: var(--slate-500);
    --text-inv: #ffffff;

    /* Shadows */
    --shadow-sm: var(--shadow-sm);
    --shadow: var(--shadow-md);
    --shadow-lg: var(--shadow-lg);
    --shadow-xl: var(--shadow-xl);

    /* Misc */
    --radius: var(--radius-md);
    --radius-lg: var(--radius-lg);
    --radius-xl: var(--radius-xl);
    --sidebar-width: 260px;
    --header-height: 72px;
    --transition: var(--transition-base);
    --aura-ripple-bg: rgba(255, 255, 255, 0.35);
}

/* --- RIPPLE CONTAINMENT & UX FIXES (Phase 07.8) --- */
.nav-link, .tab-btn, .btn, .card-header, .list-group-item, .selectable-item, .profile-tab-item, 
button, .action-btn, .profile-tabs-header, .nav-tabs, .tabs-navigation, .nav-item,
.nav-tabs a, .profile-tabs-header a, .tabs-navigation a, .aura-ripple-container {
    position: relative !important;
    overflow: hidden !important;
    transform: translateZ(0); /* Force GPU acceleration and clipping */
}

/* Issue 7: Workflow Step Bar Overflow */
.milestones-stepper, .workflow-steps-container, .step-bar-wrapper {
    display: flex !important;
    overflow-x: auto !important;
    padding-bottom: 12px !important;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--surface-2);
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Premium Scrollbar Styling */
.workflow-steps-container::-webkit-scrollbar {
    height: 6px;
    display: block !important;
}
.workflow-steps-container::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-radius: 10px;
}
.workflow-steps-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}
.workflow-steps-container {
    position: relative;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.workflow-steps-container::-webkit-scrollbar {
    height: 6px;
}

.workflow-steps-container::-webkit-scrollbar-track {
    background: transparent;
}

.workflow-steps-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.workflow-steps-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Visual Scroll Hint (Right Fade) */
.workflow-steps-container::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 100%;
    background: linear-gradient(to right, transparent, var(--surface));
    pointer-events: none;
    opacity: 0.9;
    z-index: 5;
}

/* Left Fade for symmetric discoverability when scrolled */
.workflow-steps-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to left, transparent, var(--surface));
    pointer-events: none;
    opacity: 0.6;
    z-index: 5;
}

/* Issue 8: Page Header Title Overflow */
.header-title-container h1, .page-header-title {
    max-width: 600px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Suppress TinyMCE "Unlicensed" banner globally */
.tox-notifications-container, .tox-statusbar__branding, .tox-notification, .tox-promotion, .tox-msg {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    height: 0 !important;
}

/* Ensure the ripple itself is contained */
.aura-ripple-container {
    position: absolute !important;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden !important;
    border-radius: inherit;
}

/* ── Dark Mode ───────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --background: var(--slate-900);
    --surface: var(--slate-800);
    --surface-2: var(--slate-700);
    --border: var(--slate-700);
    --text: var(--slate-50);
    --text-muted: var(--slate-400);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

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

body {
    font-family: var(--font-family-base);
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.skip-nav {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    z-index: 10000;
    transition: top 0.2s;
    text-decoration: none;
    font-weight: var(--font-weight-bold);
    border-radius: 0 0 8px 0;
}

.skip-nav:focus {
    top: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   AUTH PAGES
════════════════════════════════════════════════════════════════════════ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--primary) 100%);
    position: relative;
    padding: var(--space-4);
    overflow: hidden;
}

.auth-card {
    background: var(--surface);
    padding: 3rem 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 10;
    animation: authSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card.glass {
    background: rgba(var(--surface-rgb, 255, 255, 255), 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(var(--border-rgb, 255, 255, 255), 0.3);
}

[data-theme="dark"] .auth-card.glass {
    background: rgba(30, 41, 59, 0.92);
    border-color: rgba(255, 255, 255, 0.1);
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-logo h1 {
    color: var(--primary);
    font-weight: var(--font-weight-bold);
    font-size: 1.75rem;
    letter-spacing: -0.025em;
}

.auth-logo img {
    max-height: 70px;
    margin-bottom: var(--space-4);
}

.auth-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-8);
    line-height: 1.5;
}

@keyframes authSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   FORMS
════════════════════════════════════════════════════════════════════════ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: var(--font-weight-semibold);
    margin-bottom: 0.4rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--text);
    font-size: var(--font-size-sm);
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

[data-theme="dark"] .form-control {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
}

/* ── Form Validation States ───────────────────────────────────────── */
.form-control.is-invalid {
    border-color: var(--danger);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23ef4444' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--danger);
}

.is-invalid~.invalid-feedback {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════
   CONFIRMATION MODALS
════════════════════════════════════════════════════════════════════════ */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.confirm-overlay.active {
    opacity: 1;
}

.confirm-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-overlay.active .confirm-card {
    transform: scale(1);
}

.confirm-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.confirm-body {
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.confirm-btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.confirm-btn-cancel {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.confirm-btn-danger {
    background: var(--danger);
    color: white;
}

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

.confirm-btn:hover {
    filter: brightness(0.95);
}

/* ═══════════════════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.4rem;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-sm);
    border-radius: var(--radius);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
    gap: 0.5rem;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1.5px);
}

.btn:active {
    transform: translateY(0.5px);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff !important;
    box-shadow: 0 4px 14px 0 hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.35);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(var(--primary-h), var(--primary-s), var(--primary-l), 0.25);
}

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

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

.btn-icon i {
    font-size: 1.1rem;
    line-height: 1;
}

.btn-success {
    background: var(--color-success);
    color: white !important;
    border-color: var(--color-success-border);
}

.btn-danger {
    background: var(--color-danger);
    color: white !important;
    border-color: var(--color-danger-border);
}

.btn-sm {
    padding: var(--btn-sm-padding);
    font-size: var(--font-size-xs);
}

.btn-block {
    width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════
   LAYOUT — DASHBOARD
════════════════════════════════════════════════════════════════════════ */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    display: none;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #ffffff;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

/* ── Main content ─────────────────────────────────────────────────────── */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-8);
    min-width: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Collapsed Sidebar Logic ────────────────────────────────────────── */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width, 76px);
    padding: var(--space-4) var(--space-3);
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width, 76px);
}

.sidebar-collapsed .sidebar .sidebar-logo span,
.sidebar-collapsed .sidebar .nav-link span,
.sidebar-collapsed .sidebar .nav-text,
.sidebar-collapsed .sidebar .nav-header {
    display: none;
}

.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar-collapsed .sidebar .nav-link i,
.sidebar-collapsed #sidebarToggleBtn i {
    font-size: 1.25rem;
    margin: 0;
}

.sidebar-collapsed .sidebar .sidebar-logo {
    justify-content: center;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-4);
}

.sidebar-collapsed .sidebar .sidebar-logo img {
    max-height: 28px !important;
}

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex !important;
        position: relative;
        z-index: 2000;
    }

    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        z-index: 1100;
        width: 280px !important;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.2);
    }

    .dashboard.sidebar-active .sidebar {
        left: 0;
    }

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

    .main-content {
        margin-left: 0 !important;
        padding: var(--space-4);
    }

    .top-header {
        padding: 0 var(--space-4);
    }
}

/* ── Top Header bar ───────────────────────────────────────────────────── */
.top-header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-8);
    position: sticky;
    top: 0;
    z-index: 900;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-10);
    padding: var(--space-2) var(--space-4);
    text-decoration: none;
    color: white;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: var(--space-1);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.75rem 1rem;
    color: hsla(0, 0%, 100%, 0.7);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.nav-link:hover {
    background: hsla(0, 0%, 100%, 0.08);
    color: #ffffff;
}

.nav-link.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.3);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: var(--font-size-base);
    flex-shrink: 0;
}

.nav-text {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════
   FILTER BAR (Aura Reimagined)
   ════════════════════════════════════════════════════════════════════════ */
.filter-bar-aura {
    background: var(--surface);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    gap: var(--space-4);
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-8);
}

.filter-group {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}

.filter-group .form-label {
    margin-bottom: 4px;
    font-size: 10px;
    color: var(--text-muted);
}

.filter-group .form-control {
    padding: 0.5rem 0.75rem;
    font-size: 13px;
    height: 38px;
}


/* Cards, Stat Widgets, Tables and Badges are now in component files:
   - components/cards.css
   - components/tables.css
*/



/* ═══════════════════════════════════════════════════════════════════════
   QUICK ACTION BUTTONS (Invoice Hub)
════════════════════════════════════════════════════════════════════════ */
.quick-action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.quick-action-btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

/* Legacy filter-bar removed (use .filter-bar-aura) */

/* ═══════════════════════════════════════════════════════════════════════
   THEME TOGGLE BUTTON
════════════════════════════════════════════════════════════════════════ */
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: var(--font-size-base);
}

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

/* ═══════════════════════════════════════════════════════════════════════
   TIMELINE
════════════════════════════════════════════════════════════════════════ */
.timeline {
    position: relative;
    padding-left: var(--space-8);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-8);
}

.timeline-dot {
    position: absolute;
    left: -2.35rem;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface);
    z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
════════════════════════════════════════════════════════════════════════ */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
}

.toast {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 1rem 1.25rem;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    max-width: 380px;
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    transition: transform 0.2s;
}

.toast:hover {
    transform: translateY(-2px);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-sm);
    color: var(--text);
}

.toast-msg {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.toast-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideIn {
    from {
        transform: translateX(110%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        transform: translateX(20px);
        opacity: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   INVOICE TEMPLATE PREVIEW
════════════════════════════════════════════════════════════════════════ */
.invoice-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    max-width: 860px;
    font-family: 'Inter', sans-serif;
    color: var(--bg-sidebar);
}

.invoice-preview [contenteditable] {
    outline: none;
    border-bottom: 1px dashed transparent;
    transition: var(--transition);
    padding: 2px 4px;
    border-radius: 4px;
    cursor: text;
}

.invoice-preview [contenteditable]:hover {
    background: #f0f9ff;
    border-bottom-color: var(--primary);
}

.invoice-preview [contenteditable]:focus {
    background: #eff6ff;
    border-bottom-color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════════
   UTILITY & OVERLAYS
════════════════════════════════════════════════════════════════════════ */
.grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.text-muted {
    color: var(--text-muted);
}

.calendar-day {
    background: var(--surface);
    height: 120px;
    padding: var(--space-2);
    transition: var(--transition);
    border: 0.5px solid var(--border);
}

.calendar-day:hover {
    background: var(--surface-2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    z-index: 2;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1050;
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN (6.25)
════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        z-index: 2000;
        width: 280px !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }

    .sidebar-active .sidebar {
        left: 0;
    }

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

    .sidebar .nav-link span,
    .sidebar .nav-text,
    .sidebar .sidebar-logo span {
        display: block !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: var(--space-4);
        width: 100%;
        overflow-x: hidden;
    }

    header {
        padding: 0 var(--space-4);
        flex-wrap: wrap !important;
        height: auto !important;
        min-height: 80px;
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    header form[role="search"] {
        order: 3;
        width: 100% !important;
        margin-top: var(--space-3);
    }

    header form[role="search"] input {
        width: 100% !important;
        max-width: none !important;
    }
    
    header > div:first-of-type {
        max-width: calc(100% - 100px);
    }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 {
        grid-template-columns: 1fr !important;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .card-header .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    header h1 {
        font-size: 1.1rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGINATION
════════════════════════════════════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: var(--space-8);
    padding: var(--space-4) 0;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.page-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-2);
}

.page-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    pointer-events: none;
}

.page-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pagination-info {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: 0 var(--space-4);
}

/* ═══════════════════════════════════════════════════════════════════════
   EMPTY STATES
   ════════════════════════════════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    background: var(--surface);
    border-radius: var(--radius-lg);
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--slate-200);
    margin-bottom: var(--space-4);
    display: block;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    max-width: 320px;
    margin: 0 auto var(--space-6);
}

/* ── Skeleton Loading ─────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--slate-100) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
    display: inline-block;
    height: 1.25rem;
    width: 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION
════════════════════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    padding: 0.5rem 0 env(safe-area-inset-bottom, 0.5rem);
}

.mobile-bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.4rem 0.75rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item i {
    font-size: 1.1rem;
}

.mobile-nav-item:active {
    transform: scale(0.92);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: block;
    }
    
    /* Hide FAB on mobile since we have bottom nav */
    .fab-container {
        bottom: 5rem !important;
    }
    
    /* Add padding so content doesn't hide behind bottom nav */
    .main-content {
        padding-bottom: 5rem !important;
    }
    
    /* Responsive table: hide non-essential columns */
    .dynamic-table th:nth-child(n+4),
    .dynamic-table td:nth-child(n+4) {
        display: none;
    }
    
    .dynamic-table th:last-child,
    .dynamic-table td:last-child {
        display: table-cell;
    }
    
    /* Filter bar stacks vertically */
    .filter-bar-aura {
        flex-direction: column;
        gap: 0.75rem !important;
    }
    
    .filter-group {
        min-width: 100% !important;
    }
    
    /* View toggle smaller */
    .view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    /* Card grid single column on small screens */
    .grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .breadcrumb {
        font-size: 0.75rem !important;
    }
    
    .fab-container {
        bottom: 5rem !important;
        right: 1rem !important;
    }
    
    .fab-main {
        width: 48px !important;
        height: 48px !important;
        font-size: 1.2rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE UTILITY CLASSES
════════════════════════════════════════════════════════════════════════ */
.d-none-sm { /* populated by media query below */ visibility: visible; }
.d-none-md { /* populated by media query below */ visibility: visible; }

@media (max-width: 768px) {
    .d-none-sm { display: none !important; }
}

@media (max-width: 1024px) {
    .d-none-md { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   CONTEXTUAL TOOLTIPS
════════════════════════════════════════════════════════════════════════ */
.crm-tooltip {
    position: relative;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 700;
    margin-left: 0.4rem;
    vertical-align: middle;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.crm-tooltip:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.crm-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-sidebar);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 280px;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}

.crm-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR GROUP ANIMATIONS
════════════════════════════════════════════════════════════════════════ */
.nav-header:hover {
    color: rgba(255,255,255,0.9) !important;
}

.nav-header .group-chevron {
    opacity: 0.5;
    transition: transform 0.25s ease, opacity 0.2s;
}

.nav-header:hover .group-chevron {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════
   FIELD ERROR INLINE MESSAGES
════════════════════════════════════════════════════════════════════════ */
.field-error-msg {
    color: var(--color-danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    animation: shake 0.3s ease;
}

.field-error-msg::before {
    content: '\f06a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7rem;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.form-control.is-invalid {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* ==========================================================================
   Province (Classic) Table - High Density Grid Migration
   ========================================================================== */
.province-table-container {
    background: var(--surface);
    border: 1px solid #e0e0e0;
    margin-bottom: 2rem;
    overflow-x: auto;
}

.province-table {
    width: 100%;
    border-collapse: collapse !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 11.5px;
    color: #333;
    background: var(--surface);
}

/* Rigid Grid Borders */
.province-table th,
.province-table td {
    border: 1px solid #eee !important;
    padding: 6px 8px !important;
    vertical-align: top !important;
    line-height: 1.4;
}

.province-table thead th {
    background: #fdfdfd;
    font-weight: 700;
    color: #555;
    text-transform: none;
    white-space: nowrap;
    border-bottom: 2px solid #eee !important;
}

/* Column Specific Logic */
.province-col-action {
    width: 60px;
    text-align: center;
}

.province-action-flex {
    display: flex;
    gap: 4px;
    justify-content: center;
}

/* Iconic Square Buttons */
.province-btn-green,
.province-btn-orange {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 3px;
    color: white;
    cursor: pointer;
    font-size: 10px;
    transition: opacity 0.2s;
}

.province-btn-green {
    background: #22c55e;
}

.province-btn-orange {
    background: #f97316;
}

.province-btn-green:hover,
.province-btn-orange:hover {
    opacity: 0.85;
}

/* Date Stack & Move To Client */
.province-date-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.date-val {
    white-space: nowrap;
    color: #444;
}

.province-move-btn {
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid #2563eb;
    color: #2563eb;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.province-move-btn:hover {
    background: #2563eb;
    color: #fff;
}

/* Name Column Actions */
.province-lead-name {
    font-weight: 600;
    color: #1d4ed8;
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
}

.province-name-actions {
    display: flex;
    gap: 4px;
}

.prov-inline-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 1px 6px;
    font-size: 9.5px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
}

.note-count {
    background: #0891b2;
    color: #fff;
    padding: 0 4px;
    border-radius: 2px;
    font-size: 8.5px;
}

/* Interested Country Badge */
.province-country-badge {
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

/* Status & Remark Styling */
.province-table td:last-child {
    color: #666;
}

/* Dark Mode Support for Grid */
[data-theme="dark"] .province-table-container {
    background: #0f172a;
    border-color: #1e293b;
}

[data-theme="dark"] .province-table {
    background: #0f172a;
    color: #e2e8f0;
}

[data-theme="dark"] .province-table th,
[data-theme="dark"] .province-table td {
    border-color: #1e293b !important;
}

[data-theme="dark"] .province-table thead th {
    background: #1e293b;
    color: #94a3b8;
}

[data-theme="dark"] .province-lead-name {
    color: #60a5fa;
}

[data-theme="dark"] .prov-inline-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .province-move-btn {
    border-color: #3b82f6;
    color: #3b82f6;
    background: transparent;
}

[data-theme="dark"] .province-move-btn:hover {
    background: #3b82f6;
    color: #fff;
}