/* ==========================================================================
   GMP Business OS V6 — World-Class Enterprise UI/UX Design System
   Adheres to Apple/Google Tier & Section 08 / TR-11 Mandate:
   - Anti-Center Asymmetric Split Layouts & Bento 2.0 Hierarchy
   - Neutral Slate/Zinc Enterprise Base (#0F172A, #1E293B, #F8FAFC, #FFFFFF)
   - Single Calibrated Primary Accent (#2563EB Cobalt/Indigo)
   - Semantic Truth Badges (#059669 Verified, #D97706 Pending, #DC2626 Alert)
   - Crisp 1px Borders (#E2E8F0) & Tabular Monospace Numerals (tabular-nums)
   - Full Arabic RTL (Readex Pro) + English LTR (Plus Jakarta Sans / Inter) & 100dvh Viewport Stability
   - Zero External Google Fonts CDN Dependency
   ========================================================================== */

:root {
    --gmp-bg-primary: #F8FAFC;
    --gmp-bg-surface: #FFFFFF;
    --gmp-bg-elevated: #F1F5F9;
    --gmp-text-primary: #0F172A;
    --gmp-text-secondary: #334155;
    --gmp-text-muted: #64748B;
    --gmp-border: #E2E8F0;
    --gmp-accent: #2563EB;
    --gmp-accent-hover: #1D4ED8;
    --gmp-accent-soft: rgba(37, 99, 235, 0.09);
    --gmp-emerald: #059669;
    --gmp-emerald-soft: rgba(5, 150, 105, 0.11);
    --gmp-amber: #D97706;
    --gmp-amber-soft: rgba(217, 119, 6, 0.12);
    --gmp-rose: #DC2626;
    --gmp-rose-soft: rgba(220, 38, 38, 0.11);
    --gmp-header-bg: #0F172A;
    --gmp-sidebar-bg: #0F172A;
    --gmp-sidebar-text: #E2E8F0;
    --gmp-font-sans: 'Readex Pro', 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --gmp-font-ar: 'Readex Pro', 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --gmp-font-mono: 'JetBrains Mono', monospace;
}

html[data-gmp-theme="dark"] {
    --gmp-bg-primary: #0F172A;
    --gmp-bg-surface: #1E293B;
    --gmp-bg-elevated: #0F172A;
    --gmp-text-primary: #F8FAFC;
    --gmp-text-secondary: #CBD5E1;
    --gmp-text-muted: #94A3B8;
    --gmp-border: rgba(255, 255, 255, 0.10);
    --gmp-accent: #3B82F6;
    --gmp-accent-hover: #2563EB;
    --gmp-accent-soft: rgba(59, 130, 246, 0.16);
    --gmp-header-bg: #0F172A;
    --gmp-sidebar-bg: #0F172A;
}

html[dir="rtl"] body {
    font-family: var(--gmp-font-ar) !important;
}

html[dir="ltr"] body {
    font-family: var(--gmp-font-sans) !important;
}

.gmp-mono,
.total_sell,
.net,
.invoice_due,
.total_purchase,
.purchase_due,
.total_expense,
.display_currency {
    font-family: var(--gmp-font-mono) !important;
    font-variant-numeric: tabular-nums;
}

/* Viewport stability */
body,
.thetop,
#scrollable-container {
    min-height: 100dvh;
    overflow-x: hidden;
    background-color: var(--gmp-bg-primary);
}

/* Header & Sidebar refinement */
.theme-header-bg {
    background: var(--gmp-header-bg) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.theme-logo-bg {
    background: #0F172A !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.theme-btn-bg {
    background-color: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease !important;
}

.theme-btn-bg:hover {
    background-color: var(--gmp-accent) !important;
    border-color: var(--gmp-accent) !important;
}

.theme-btn-bg:active {
    transform: scale(0.98);
}

/* GMP OS Command Ribbon (12 Functional Hubs + Forensic & Financial Hubs) */
.gmp-os-ribbon {
    background: var(--gmp-bg-surface);
    border-bottom: 1px solid var(--gmp-border);
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.gmp-os-ribbon-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.7rem;
    border-radius: 0.5rem;
    background: var(--gmp-accent-soft);
    color: var(--gmp-accent);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.gmp-os-hub-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

.gmp-os-hub-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.68rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gmp-text-secondary);
    background: transparent;
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none !important;
    transition: all 0.15s ease;
}

.gmp-os-hub-pill:hover,
.gmp-os-hub-pill.active {
    color: var(--gmp-accent);
    background: var(--gmp-accent-soft);
    border-color: rgba(37, 99, 235, 0.28);
}

/* Interactive Filter & Role Switcher Bar */
.gmp-filter-bar {
    background: var(--gmp-bg-surface);
    border: 1px solid var(--gmp-border);
    border-radius: 0.75rem;
    padding: 0.85rem 1.15rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
}

.gmp-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    max-width: 100%;
    min-width: 0;
}

.gmp-filter-select {
    padding: 0.38rem 0.75rem;
    border: 1px solid var(--gmp-border);
    border-radius: 0.5rem;
    background: var(--gmp-bg-elevated);
    color: var(--gmp-text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    max-width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
}

.gmp-role-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.68rem;
    border-radius: 0.45rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--gmp-text-secondary);
    border: 1px solid var(--gmp-border);
    background: var(--gmp-bg-elevated);
    text-decoration: none !important;
    transition: all 0.15s ease;
}

.gmp-role-pill.active,
.gmp-role-pill:hover {
    background: var(--gmp-accent);
    color: #FFFFFF !important;
    border-color: var(--gmp-accent);
}

/* Bento 2.0 Grid & Cards */
.gmp-bento-shell {
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

.gmp-bento-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--gmp-border);
}

.gmp-bento-title {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--gmp-text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.gmp-bento-subtitle {
    font-size: 0.88rem;
    color: var(--gmp-text-secondary);
    margin-top: 0.25rem;
}

.gmp-bento-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.gmp-col-12 { grid-column: span 12 / span 12; }
.gmp-col-8  { grid-column: span 12 / span 12; }
.gmp-col-7  { grid-column: span 12 / span 12; }
.gmp-col-6  { grid-column: span 12 / span 12; }
.gmp-col-5  { grid-column: span 12 / span 12; }
.gmp-col-4  { grid-column: span 12 / span 12; }
.gmp-col-3  { grid-column: span 12 / span 12; }

@media (min-width: 768px) {
    .gmp-col-6 { grid-column: span 6 / span 6; }
    .gmp-col-4 { grid-column: span 6 / span 6; }
    .gmp-col-3 { grid-column: span 6 / span 6; }
}

@media (min-width: 1200px) {
    .gmp-col-8 { grid-column: span 8 / span 8; }
    .gmp-col-7 { grid-column: span 7 / span 7; }
    .gmp-col-6 { grid-column: span 6 / span 6; }
    .gmp-col-5 { grid-column: span 5 / span 5; }
    .gmp-col-4 { grid-column: span 4 / span 4; }
    .gmp-col-3 { grid-column: span 3 / span 3; }
}

.gmp-panel {
    background: var(--gmp-bg-surface);
    border: 1px solid var(--gmp-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.gmp-panel:hover {
    border-color: rgba(37, 99, 235, 0.35);
}

.gmp-panel-dark {
    background: #0F172A;
    color: #F8FAFC;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.gmp-kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gmp-text-muted);
    font-weight: 600;
}

.gmp-kpi-value {
    font-family: var(--gmp-font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--gmp-text-primary);
    margin-top: 0.35rem;
}

.gmp-kpi-source {
    font-size: 0.71rem;
    color: var(--gmp-text-muted);
    font-family: var(--gmp-font-mono);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

/* Semantic Truth State Badges */
.gmp-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.71rem;
    font-weight: 600;
    white-space: nowrap;
}

.gmp-badge-verified {
    background: var(--gmp-emerald-soft);
    color: var(--gmp-emerald);
    border: 1px solid rgba(5, 150, 105, 0.28);
}

.gmp-badge-sandbox,
.gmp-badge-pending {
    background: var(--gmp-amber-soft);
    color: var(--gmp-amber);
    border: 1px solid rgba(217, 119, 6, 0.30);
}

.gmp-badge-alert,
.gmp-badge-danger {
    background: var(--gmp-rose-soft);
    color: var(--gmp-rose);
    border: 1px solid rgba(220, 38, 38, 0.30);
}

.gmp-badge-isolated {
    background: rgba(100, 116, 139, 0.12);
    color: #475569;
    border: 1px solid rgba(100, 116, 139, 0.25);
}

/* Dark theme surface & component contrast overrides */
html[data-gmp-theme="dark"] {
    --gmp-surface: #1E293B;
    --gmp-surface-elevated: #0F172A;
}

:root {
    --gmp-surface: var(--gmp-bg-surface);
    --gmp-surface-elevated: var(--gmp-bg-elevated);
}

@view-transition {
    navigation: auto;
}

/* Suppress stuck Pace.js top-right spinner */
.pace,
.pace-progress,
.pace-activity {
    display: none !important;
    pointer-events: none !important;
}

/* 60fps GPU-composited spring micro-physics (transform & opacity only) */
.gmp-os-hub-pill,
.gmp-role-pill,
.gmp-ui-btn,
.btn,
.tw-dw-btn {
    transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    will-change: transform;
}

.gmp-os-hub-pill:active,
.gmp-role-pill:active,
.gmp-ui-btn:active,
.btn:active,
.tw-dw-btn:active {
    transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

html[data-gmp-theme="dark"] body,
html[data-gmp-theme="dark"] main,
html[data-gmp-theme="dark"] #scrollable-container,
html[data-gmp-theme="dark"] .content-wrapper {
    background-color: #0F172A !important;
    color: #F8FAFC !important;
}

html[data-gmp-theme="dark"] .side-bar,
html[data-gmp-theme="dark"] #side-bar,
html[data-gmp-theme="dark"] .tw-bg-white,
html[data-gmp-theme="dark"] .box,
html[data-gmp-theme="dark"] .panel,
html[data-gmp-theme="dark"] .modal-content,
html[data-gmp-theme="dark"] .nav-tabs-custom,
html[data-gmp-theme="dark"] .nav-tabs-custom > .tab-content {
    background-color: #1E293B !important;
    color: #F8FAFC !important;
    border-color: rgba(255, 255, 255, 0.10) !important;
}

html[data-gmp-theme="dark"] .form-control,
html[data-gmp-theme="dark"] input[type="text"],
html[data-gmp-theme="dark"] input[type="number"],
html[data-gmp-theme="dark"] input[type="email"],
html[data-gmp-theme="dark"] input[type="password"],
html[data-gmp-theme="dark"] input[type="search"],
html[data-gmp-theme="dark"] select,
html[data-gmp-theme="dark"] textarea,
html[data-gmp-theme="dark"] .select2-container--default .select2-selection--single,
html[data-gmp-theme="dark"] .select2-container--default .select2-selection--multiple,
html[data-gmp-theme="dark"] .input-group-addon {
    background-color: #0F172A !important;
    color: #F8FAFC !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
}

html[data-gmp-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #F8FAFC !important;
}

html[data-gmp-theme="dark"] .table > thead > tr > th,
html[data-gmp-theme="dark"] .table > tbody > tr > td,
html[data-gmp-theme="dark"] .table > tfoot > tr > th,
html[data-gmp-theme="dark"] .table > tfoot > tr > td,
html[data-gmp-theme="dark"] .table-bordered,
html[data-gmp-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #1E293B !important;
    color: #F1F5F9 !important;
    border-color: rgba(255, 255, 255, 0.10) !important;
}

html[data-gmp-theme="dark"] .tw-text-gray-900,
html[data-gmp-theme="dark"] .tw-text-gray-800,
html[data-gmp-theme="dark"] .tw-text-gray-700,
html[data-gmp-theme="dark"] .tw-text-gray-600,
html[data-gmp-theme="dark"] h1,
html[data-gmp-theme="dark"] h2,
html[data-gmp-theme="dark"] h3,
html[data-gmp-theme="dark"] h4,
html[data-gmp-theme="dark"] label,
html[data-gmp-theme="dark"] table.dataTable tbody tr {
    color: #F1F5F9 !important;
    background-color: transparent !important;
}

/* RTL Logical Alignment & Sidebar Mirroring */
html[dir="rtl"] .side-bar,
html[dir="rtl"] #side-bar {
    border-right: none !important;
    border-left: 1px solid var(--gmp-border) !important;
}

html[dir="rtl"] .pull-right {
    float: left !important;
}

html[dir="rtl"] .pull-left {
    float: right !important;
}

html[dir="rtl"] .text-right {
    text-align: left !important;
}

html[dir="rtl"] .text-left {
    text-align: right !important;
}

/* Mobile Bottom Quick-Dock */
.gmp-mobile-dock {
    display: none;
}

@media (max-width: 767px) {
    .gmp-bento-shell {
        padding: 1rem 0.85rem 4.5rem 0.85rem;
    }
    .gmp-mobile-dock {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: rgba(15, 23, 42, 0.96);
        backdrop-filter: blur(12px);
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        padding: 0.45rem 0.5rem;
        padding-bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        align-items: center;
    }
    .gmp-mobile-dock a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        color: #94A3B8;
        font-size: 0.68rem;
        font-weight: 600;
        text-decoration: none !important;
    }
    .gmp-mobile-dock a.active,
    .gmp-mobile-dock a:hover {
        color: #3B82F6;
    }
}

@media (max-width: 991px) {
    html,
    body,
    .thetop,
    main,
    #scrollable-container,
    .wrapper,
    .content-wrapper,
    .right-side,
    .main-footer {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    .gmp-bento-shell {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 0.85rem 0.75rem 4.5rem 0.75rem !important;
    }
    .gmp-bento-header,
    .gmp-bento-header > div,
    .gmp-panel,
    fieldset,
    .file-input,
    .input-group {
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .gmp-badge {
        white-space: normal !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .gmp-kpi-value {
        font-size: 1.35rem !important;
    }
    .gmp-auth-form-pane {
        order: -1;
        padding: 1.35rem !important;
    }
}

.tour-backdrop,
.popover.tour,
.tour-step-backdrop {
    display: none !important;
}

/* GBO-29: Keyboard Focus Order, Mobile Table Reflow & Print Styles */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--gmp-accent) !important;
    outline-offset: 2px !important;
}

.gmp-table-wrap,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Header notification dropdown: keep strictly hidden until .open is toggled in both LTR and RTL */
.notifications-menu:not(.open) > .dropdown-menu {
    display: none !important;
}

.notifications-menu.open > .dropdown-menu {
    display: block !important;
    max-height: min(75vh, 480px) !important;
    height: auto !important;
}

html[dir="rtl"] .notifications-menu > .dropdown-menu {
    left: 0 !important;
    right: auto !important;
}

@media print {
    .no-print,
    .gmp-os-ribbon,
    .gmp-mobile-dock,
    .side-bar,
    #side-bar,
    .main-sidebar,
    .main-header {
        display: none !important;
    }
    body,
    .thetop,
    #scrollable-container,
    .gmp-bento-shell,
    .gmp-panel {
        background: #FFFFFF !important;
        color: #000000 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }
}

