/* ==========================================================================
   BHAVITRAMAI OWNER PORTAL - UNIVERSAL GLOBAL MOBILE RESPONSIVE ENGINE
   ========================================================================== */

/* 1. Global MudTabs & Tab Navigation Overflow Safety */
.mud-tabs-toolbar,
.mud-tabs-tabbar,
[role="tablist"],
.nav-tabs,
.app-tabs {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
}
.mud-tabs-toolbar::-webkit-scrollbar,
.mud-tabs-tabbar::-webkit-scrollbar,
[role="tablist"]::-webkit-scrollbar,
.nav-tabs::-webkit-scrollbar,
.app-tabs::-webkit-scrollbar {
    display: none !important;
}
.mud-tab {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    min-width: auto !important;
}

/* 2. Global Table Scroll Safety */
.mud-table-container,
.table-responsive {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}
.mud-table-root {
    min-width: 100% !important;
}

/* 3. Global Code, Monospace & Pre Wrappers */
pre, code.block, .app-code-snippet {
    max-width: 100% !important;
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-break: break-all !important;
}

/* 4. Global Zero-Squish Responsive Grid Engine (< 640px) */
@media (max-width: 639px) {
    .grid-cols-3:not([class*="sm:"]):not([class*="md:"]):not(.keep-grid),
    .grid-cols-4:not([class*="sm:"]):not([class*="md:"]):not(.keep-grid),
    .grid-cols-5:not([class*="sm:"]):not([class*="md:"]):not(.keep-grid) {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 480px) {
    .grid-cols-2:not([class*="sm:"]):not([class*="md:"]):not(.keep-grid):not(.app-action-grid) {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
}

/* 5. Mobile Phone System Rules (320px - 767px) */
@media (max-width: 767px) {
    .mud-main-content {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* Auto-scale MudPaper and Card paddings on mobile */
    .mud-paper.pa-6, .mud-paper.pa-8, .mud-paper.pa-5,
    .glass-panel.p-6, .glass-panel.p-8,
    .p-6, .p-8 {
        padding: 0.875rem !important;
    }
    .mud-paper.px-6, .mud-paper.px-8,
    .px-6, .px-8 {
        padding-left: 0.875rem !important;
        padding-right: 0.875rem !important;
    }
    .mud-paper.py-6, .mud-paper.py-8,
    .py-6, .py-8 {
        padding-top: 0.875rem !important;
        padding-bottom: 0.875rem !important;
    }

    /* Global Dialog / Modal / Sheet Guard */
    .mud-dialog {
        max-width: calc(100vw - 20px) !important;
        margin: 10px !important;
        border-radius: 14px !important;
    }
    .mud-dialog-content {
        padding: 12px !important;
    }
    .mud-dialog-actions {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 10px 12px !important;
    }
    .mud-dialog-actions > button {
        flex: 1 1 calc(50% - 6px) !important;
        margin: 0 !important;
    }

    /* Table cells compact padding */
    .mud-table-cell {
        padding: 8px 10px !important;
        font-size: 0.75rem !important;
    }
    .mud-table-cell-actions,
    .table-actions {
        white-space: nowrap !important;
    }

    /* Temporary Drawer Mobile Full-Width Guard */
    .mud-drawer-temporary {
        max-width: 100vw !important;
    }

    /* Auto-stack side-by-side input fields inside flex containers on mobile */
    .d-flex:has(> .mud-input-control),
    .d-flex:has(> div > .mud-input-control) {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    /* Ensure action button groups wrap cleanly */
    .d-flex.align-center.gap-2:has(> button),
    .d-flex.align-center.gap-2:has(> a),
    .flex.items-center.gap-2:has(> button),
    .flex.items-center.gap-2:has(> a),
    .flex.items-center.gap-3:has(> button),
    .flex.items-center.gap-3:has(> a) {
        flex-wrap: wrap !important;
    }

    /* Fixed-width utilities reset on mobile (except within horizontal scroll areas) */
    :not(.overflow-x-auto):not(.mud-table-container) > [class*="min-w-["] {
        min-width: 0 !important;
    }
    .w-44, .w-48, .w-52, .w-56, .w-60, .w-64, .w-72, .w-80 {
        max-width: 100% !important;
    }

    /* Compact alerts on mobile */
    .mud-alert {
        padding: 8px 12px !important;
        font-size: 0.75rem !important;
    }
    .mud-alert-message {
        font-size: 0.75rem !important;
        word-break: break-word !important;
    }
}

/* Brand Logo SVG High-Fidelity Rendering */
.brand-logo-svg {
    display: block !important;
    flex-shrink: 0 !important;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    user-select: none;
    -webkit-user-drag: none;
}

/* ==========================================================================
   BHAVITRAMAI OWNER PORTAL - DUAL-THEME COMPLIANCE OVERRIDES
   When data-theme="light" or class "light" is active on <html>, force dark-slate
   utility classes to resolve to CSS custom properties so light mode is 100%
   readable without breaking dark mode.
   ========================================================================== */

/* --- Background: Deep Surfaces & Cards (bg-slate-950, bg-slate-900 and opacities) --- */
[data-theme="light"] .bg-slate-950,
.light .bg-slate-950,
[data-theme="light"] .bg-slate-950\/40,
.light .bg-slate-950\/40,
[data-theme="light"] .bg-slate-950\/60,
.light .bg-slate-950\/60,
[data-theme="light"] .bg-slate-950\/70,
.light .bg-slate-950\/70,
[data-theme="light"] .bg-slate-950\/80,
.light .bg-slate-950\/80,
[data-theme="light"] .bg-slate-900,
.light .bg-slate-900,
[data-theme="light"] .bg-slate-900\/40,
.light .bg-slate-900\/40,
[data-theme="light"] .bg-slate-900\/50,
.light .bg-slate-900\/50,
[data-theme="light"] .bg-slate-900\/60,
.light .bg-slate-900\/60,
[data-theme="light"] .bg-slate-900\/70,
.light .bg-slate-900\/70,
[data-theme="light"] .bg-slate-900\/80,
.light .bg-slate-900\/80,
[data-theme="light"] .bg-slate-900\/90,
.light .bg-slate-900\/90,
[data-theme="light"] .bg-slate-900\/95,
.light .bg-slate-900\/95 {
    background-color: var(--bg-surface) !important;
}

/* --- Background: Elevated Surfaces & Panels (bg-slate-800, bg-slate-700 and opacities) --- */
[data-theme="light"] .bg-slate-800,
.light .bg-slate-800,
[data-theme="light"] .bg-slate-800\/20,
.light .bg-slate-800\/20,
[data-theme="light"] .bg-slate-800\/30,
.light .bg-slate-800\/30,
[data-theme="light"] .bg-slate-800\/40,
.light .bg-slate-800\/40,
[data-theme="light"] .bg-slate-800\/50,
.light .bg-slate-800\/50,
[data-theme="light"] .bg-slate-800\/60,
.light .bg-slate-800\/60,
[data-theme="light"] .bg-slate-800\/80,
.light .bg-slate-800\/80,
[data-theme="light"] .bg-slate-700,
.light .bg-slate-700,
[data-theme="light"] .bg-slate-700\/40,
.light .bg-slate-700\/40,
[data-theme="light"] .bg-slate-700\/60,
.light .bg-slate-700\/60,
[data-theme="light"] .bg-slate-600,
.light .bg-slate-600 {
    background-color: var(--bg-surface-elevated) !important;
}

/* --- Borders (border-slate-800, border-slate-700 and opacities) --- */
[data-theme="light"] .border-slate-800,
.light .border-slate-800,
[data-theme="light"] .border-slate-800\/30,
.light .border-slate-800\/30,
[data-theme="light"] .border-slate-800\/40,
.light .border-slate-800\/40,
[data-theme="light"] .border-slate-800\/50,
.light .border-slate-800\/50,
[data-theme="light"] .border-slate-800\/60,
.light .border-slate-800\/60,
[data-theme="light"] .border-slate-800\/80,
.light .border-slate-800\/80,
[data-theme="light"] .border-slate-700,
.light .border-slate-700,
[data-theme="light"] .border-slate-700\/50,
.light .border-slate-700\/50 {
    border-color: var(--border-card) !important;
}

/* --- Text Primary (text-white, text-slate-200, text-slate-300) --- */
[data-theme="light"] .text-white:not(.keep-white),
.light .text-white:not(.keep-white) {
    color: var(--text-primary) !important;
}

/* Retain crisp white on vibrant brand buttons & pills in light mode */
[data-theme="light"] .bg-blue-600 .text-white,
[data-theme="light"] .bg-rose-600 .text-white,
[data-theme="light"] .bg-emerald-600 .text-white,
[data-theme="light"] .bg-emerald-500 .text-white,
[data-theme="light"] .btn-neon .text-white,
[data-theme="light"] button.bg-blue-600,
[data-theme="light"] button.bg-rose-600,
[data-theme="light"] button.bg-emerald-600,
[data-theme="light"] a.bg-blue-600,
[data-theme="light"] a.bg-emerald-600,
.light .bg-blue-600 .text-white,
.light .bg-rose-600 .text-white,
.light .bg-emerald-600 .text-white,
.light .btn-neon .text-white {
    color: #FFFFFF !important;
}

[data-theme="light"] .text-slate-200,
.light .text-slate-200,
[data-theme="light"] .text-slate-300,
.light .text-slate-300 {
    color: var(--text-primary) !important;
}

/* --- Text Secondary (text-slate-400) --- */
[data-theme="light"] .text-slate-400,
.light .text-slate-400 {
    color: var(--text-secondary) !important;
}

/* --- Text Muted (text-slate-500, text-slate-600) --- */
[data-theme="light"] .text-slate-500,
.light .text-slate-500,
[data-theme="light"] .text-slate-600,
.light .text-slate-600 {
    color: var(--text-muted) !important;
}

/* --- Form Controls & Inputs (Auto theme-adapt raw HTML controls) --- */
[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not(.btn),
.light input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not(.btn),
[data-theme="light"] select,
.light select,
[data-theme="light"] textarea,
.light textarea {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

/* --- Placeholders --- */
[data-theme="light"] ::placeholder,
.light ::placeholder,
[data-theme="light"] .placeholder-slate-500::placeholder,
.light .placeholder-slate-500::placeholder,
[data-theme="light"] .placeholder-slate-400::placeholder,
.light .placeholder-slate-400::placeholder {
    color: var(--text-muted) !important;
}

/* --- Dividers --- */
[data-theme="light"] [class*="divide-slate-800"] > :not([hidden]) ~ :not([hidden]),
.light [class*="divide-slate-800"] > :not([hidden]) ~ :not([hidden]),
[data-theme="light"] [class*="divide-slate-700"] > :not([hidden]) ~ :not([hidden]),
.light [class*="divide-slate-700"] > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--border-subtle) !important;
}

/* --- Glass Panels in Light Mode --- */
[data-theme="light"] .glass-panel,
.light .glass-panel {
    background-color: rgba(255, 255, 255, 0.92) !important;
    border-color: var(--border-card) !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05) !important;
}

/* --- Hover State Overrides --- */
[data-theme="light"] .hover\:bg-slate-800\/50:hover,
.light .hover\:bg-slate-800\/50:hover,
[data-theme="light"] .hover\:bg-slate-800:hover,
.light .hover\:bg-slate-800:hover,
[data-theme="light"] .hover\:bg-slate-900:hover,
.light .hover\:bg-slate-900:hover {
    background-color: var(--bg-surface-elevated) !important;
}

[data-theme="light"] .hover\:text-white:hover,
.light .hover\:text-white:hover {
    color: var(--text-primary) !important;
}

/* --- Canonical Semantic Utility Classes --- */
.theme-card             { background-color: var(--bg-card) !important; }
.theme-surface          { background-color: var(--bg-surface) !important; }
.theme-surface-elevated { background-color: var(--bg-surface-elevated) !important; }
.theme-border           { border-color: var(--border-subtle) !important; }
.theme-text-primary     { color: var(--text-primary) !important; }
.theme-text-secondary   { color: var(--text-secondary) !important; }
.theme-text-muted       { color: var(--text-muted) !important; }
.theme-input {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}
.theme-input:focus {
    border-color: var(--brand-neon) !important;
    outline: none !important;
}

/* ==========================================================================
   STANDARDIZED BUTTONS, TABS & FILTER BAR GEOMETRY
   ========================================================================== */
.app-header-btn,
button.mud-button-root.app-header-btn,
a.mud-button-root.app-header-btn {
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding: 0 12px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 32px !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: all 0.15s ease-in-out !important;
}
.app-header-btn .mud-button-label,
button.mud-button-root.app-header-btn .mud-button-label {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    gap: 6px !important;
}
.app-header-btn .mud-icon-root,
button.mud-button-root.app-header-btn .mud-icon-root {
    width: 15px !important;
    height: 15px !important;
    font-size: 15px !important;
}

/* Natural Case on Tabs and Table Headers (No uppercase forcing) */
.mud-tab, .mud-tab-slider, .mud-tabs-tabbar, [role="tab"] {
    text-transform: none !important;
    letter-spacing: normal !important;
}
table thead th, .mud-table-head th, .mud-table-cell.mud-table-header-cell, th {
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Standardized Compact Filter Bar Controls */
.app-filter-input {
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 8px !important;
    font-size: 0.75rem !important;
}
.app-filter-select {
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 8px !important;
    font-size: 0.75rem !important;
}
.app-filter-reset {
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 8px !important;
    font-size: 0.75rem !important;
}

/* ==========================================================================
   THEME TOKENS: UNIFIED BRAND COLOR MAPPING
   ========================================================================== */
:root {
    --primary: var(--brand-neon, #00C87A);
    --primary-bg-subtle: rgba(0, 200, 122, 0.12);
}
[data-theme="dark"], .dark {
    --primary: var(--brand-neon, #00F59B);
    --primary-bg-subtle: rgba(0, 245, 155, 0.12);
}

/* ==========================================================================
   UNIVERSAL CLEAN UI: HIDE SUBTITLES, SUBHEADERS & HEADER ICONS
   Applies across 100% of pages, modal dialogs, cards, and banners
   ========================================================================== */

/* 1. Page Header Geometric Optimization */
.app-page-header {
    padding-bottom: 0.625rem !important;
    margin-bottom: 0.875rem !important;
}

/* 2. Universal Subtitle & Subheader Suppression Across FULL Project */
.app-page-header p,
.app-page-subtitle,
.page-subtitle,
.sub-header,
.section-subtitle,
.section-subheading,
.section-description,
.banner-subtitle,
.mud-dialog-title p,
.mud-dialog-title .mud-typography-caption,
.mud-dialog-title .mud-typography-body2,
.mud-dialog-title small,
.app-modal-header p,
.modal-subtitle,
.dialog-subtitle,
.mud-card-header-content p,
.mud-card-header-content .mud-typography-body2,
.card-subtitle,
.panel-subtitle,
.stat-card .text-xs.truncate {
    display: none !important;
}

/* 3. Universal Header Title Icon Suppression (Preserving action & close buttons) */
.app-page-header > div:first-child .mud-icon-root,
.app-page-header > div:first-child svg,
.app-page-header [aria-hidden="true"],
.app-page-header .shrink-0:has(.mud-icon-root),
.app-modal-header [aria-hidden="true"],
.app-modal-header > div:first-child .mud-icon-root,
.app-modal-header > div:first-child svg:not(button svg),
.mud-dialog-title .mud-icon-root,
.mud-dialog-title svg:not(.mud-dialog-close-icon svg):not(button svg),
.mud-dialog-title [aria-hidden="true"],
.mud-dialog-title div:has(> .mud-icon-root):not(:has(.mud-typography)),
.mud-dialog-title .w-8.h-8:has(svg),
.mud-dialog-title .w-9.h-9:has(svg),
.mud-dialog-title .w-10.h-10:has(svg),
.mud-card-header-avatar,
.mud-card-header .mud-icon-root {
    display: none !important;
}


/* MudBlazor Body Icons Single Color */
.mud-icon-color-info,
.mud-icon-color-warning,
.mud-icon-color-secondary,
.mud-icon-color-dark {
    color: var(--primary) !important;
}

/* MudBlazor Progress Bars Single Color */
.mud-progress-linear-color-info .mud-progress-linear-bar,
.mud-progress-linear-color-warning .mud-progress-linear-bar,
.mud-progress-linear-color-secondary .mud-progress-linear-bar {
    background-color: var(--primary) !important;
}
.mud-progress-linear-color-info,
.mud-progress-linear-color-warning,
.mud-progress-linear-color-secondary {
    background-color: var(--primary-bg-subtle) !important;
}

/* MudBlazor Chips Single Color */
.mud-chip-color-info,
.mud-chip-color-warning,
.mud-chip-color-secondary {
    background-color: var(--primary-bg-subtle) !important;
    color: var(--primary) !important;
    border: 1px solid rgba(0, 200, 122, 0.25) !important;
}

/* Metric & Stat Cards Single Color Normalization */
.stat-card div[style*="background-color"],
.stat-card .absolute[style*="background-color"] {
    background-color: var(--primary) !important;
}
.stat-card .mud-icon-root {
    color: var(--primary) !important;
}

/* ==========================================================================
   UNIVERSAL CLEAN UI & SINGLE-COLOR SYSTEMIC NORMALIZATION
   ========================================================================== */

/* 1. Universal Form Helper Text Suppression (Validation errors .mud-input-error remain visible) */
.mud-input-helper-text,
.mud-helper-text,
.form-helper-text,
.mud-input-control-helper-text {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 2. Universal UUID & Internal Database Key Suppression */
.entity-uuid,
.db-key,
.system-uuid,
[data-field="uuid"],
[data-test="uuid"],
[data-field="id"]:not(button):not(input) {
    display: none !important;
}

/* 3. Universal Tab Subtext & Subheader Suppression */
.mud-tab-panel-subtext,
.tab-subtext,
.tab-subheader,
.tab-caption,
.tab-description,
.tab-header-caption {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 4. Decorative Header Icons Suppression */
.app-card-header-icon,
.card-title-icon,
.header-title-icon,
.mud-card-header-avatar {
    display: none !important;
}

/* 5. Full Body Single Brand Color Enforcement */
.app-metric-card,
[class*="app-metric-card"] {
    border-color: var(--primary) !important;
}
.app-metric-card-icon,
.app-metric-icon {
    color: var(--primary) !important;
}

/* ── Global Bento Card & Spacious Table Polish ── */
.app-card,
.mud-paper {
    border-radius: 16px !important;
    border: 1px solid var(--border-card) !important;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.app-table-container,
.table-container {
    border-radius: 16px;
    overflow: hidden;
}

table th,
.mud-table-head th,
.mud-table-cell.mud-table-header-cell {
    padding: 0.75rem 1rem !important;
    font-size: 0.75rem !important;
    font-weight: 600;
    text-transform: none !important;
    letter-spacing: normal !important;
}

table td,
.mud-table-body .mud-table-cell:not(.mud-table-header-cell) {
    padding: 0.75rem 1rem !important;
    font-size: 0.8125rem !important;
}

.tnum {
    font-variant-numeric: tabular-nums lining-nums;
}



