/* ==========================================================================
   MH "Liquid Glass" skin — inspired by Apple's iOS 26 design language.

   Opt-in / opt-out via <html data-skin="liquid">, set in base.html's <head>
   from localStorage('skin') (or ?skin=liquid / ?skin=classic in any URL).
   EVERY rule is scoped under html[data-skin="liquid"], so with the classic
   skin this file is inert. Works with both data-theme="dark" and "light".

   Principles:
     - A colourful, slowly drifting "wallpaper" behind everything — glass
       needs something to refract, like the iPhone home screen.
     - Surfaces are translucent + heavily blurred/saturated, with a bright
       specular rim on the top edge (the "liquid" highlight).
     - Capsule-shaped controls, large continuous corner radii, SF-style type.
     - Mostly token-driven: pages already consume --card-bg / --input-bg /
       --glass-border..., so redefining those restyles most of the app.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */

html[data-skin="liquid"] {
    color-scheme: dark;

    --lg-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Hebrew", "Rubik", "Segoe UI", sans-serif;
    --lg-spring: cubic-bezier(0.32, 0.72, 0, 1);

    /* Wallpaper */
    --lg-base: #070a18;
    --lg-blob-1: rgba(10, 110, 255, 0.85);   /* iOS blue   */
    --lg-blob-2: rgba(135, 60, 255, 0.75);   /* violet     */
    --lg-blob-3: rgba(0, 190, 180, 0.6);     /* teal       */
    --lg-blob-4: rgba(255, 50, 130, 0.5);    /* pink       */

    /* Glass material */
    --lg-glass: rgba(255, 255, 255, 0.075);
    --lg-glass-strong: rgba(30, 32, 44, 0.62);
    --lg-glass-hover: rgba(255, 255, 255, 0.11);
    --lg-rim: rgba(255, 255, 255, 0.16);
    --lg-specular: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.04), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    --lg-drop: 0 18px 50px -20px rgba(0, 0, 0, 0.65), 0 2px 6px rgba(0, 0, 0, 0.18);
    --lg-blur: blur(28px) saturate(185%);
    --lg-blur-strong: blur(44px) saturate(200%);
    --lg-fill: rgba(120, 120, 128, 0.2);     /* iOS tertiary fill */

    /* App tokens (override base.html's) */
    --bg-body: var(--lg-base);
    --bg-gradient: none;
    --sidebar-bg: rgba(22, 24, 34, 0.5);
    --card-bg: var(--lg-glass);
    --glass-bg: var(--lg-glass-strong);
    --modal-bg: rgba(28, 30, 42, 0.78);
    --primary: #0a84ff;
    --primary-glow: rgba(10, 132, 255, 0.35);
    --primary-gradient: linear-gradient(180deg, #3b9dff 0%, #0a6cf0 100%);
    --accent-gold: #ffd60a;
    --secondary: #30d158;
    --secondary-glow: rgba(48, 209, 88, 0.3);
    --danger: #ff453a;
    --danger-glow: rgba(255, 69, 58, 0.3);
    --warning: #ff9f0a;
    --text-main: #f5f5f7;
    --text-muted: rgba(235, 235, 245, 0.62);
    --text-inverse: #000000;
    --glass-border: 1px solid var(--lg-rim);
    --glass-border-bright: 1px solid rgba(255, 255, 255, 0.26);
    --glass-shadow: var(--lg-drop);
    --neon-shadow: 0 8px 26px -8px var(--primary-glow);
    --input-bg: rgba(255, 255, 255, 0.06);
    --input-border: 1px solid rgba(255, 255, 255, 0.13);
    --input-focus-bg: rgba(255, 255, 255, 0.1);
    --table-row-bg: transparent;
    --table-row-hover: rgba(255, 255, 255, 0.055);
    --table-border: 1px solid rgba(255, 255, 255, 0.07);
    --btn-text: #ffffff;
    --menu-hover-bg: rgba(10, 132, 255, 0.2);
    --menu-hover-text: #ffffff;

    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 30px;
    --shadow-sm: var(--lg-specular), 0 8px 24px -14px rgba(0, 0, 0, 0.5);
    --shadow-md: var(--lg-specular), var(--lg-drop);
    --shadow-lg: var(--lg-specular), 0 30px 70px -24px rgba(0, 0, 0, 0.75);
    --ring: 0 0 0 4px rgba(10, 132, 255, 0.32);
    --transition: 0.35s var(--lg-spring);
}

html[data-skin="liquid"][data-theme="light"] {
    color-scheme: light;

    --lg-base: #e9edf6;
    --lg-blob-1: rgba(90, 170, 255, 0.55);
    --lg-blob-2: rgba(190, 150, 255, 0.45);
    --lg-blob-3: rgba(110, 230, 205, 0.45);
    --lg-blob-4: rgba(255, 170, 200, 0.45);

    --lg-glass: rgba(255, 255, 255, 0.5);
    --lg-glass-strong: rgba(255, 255, 255, 0.72);
    --lg-glass-hover: rgba(255, 255, 255, 0.66);
    --lg-rim: rgba(255, 255, 255, 0.75);
    --lg-specular: inset 0 1px 0 rgba(255, 255, 255, 0.95), inset 0 -1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
    --lg-drop: 0 18px 44px -20px rgba(30, 45, 90, 0.28), 0 2px 6px rgba(30, 45, 90, 0.06);
    --lg-fill: rgba(118, 118, 128, 0.12);

    --sidebar-bg: rgba(255, 255, 255, 0.45);
    --modal-bg: rgba(250, 250, 253, 0.86);
    --primary: #007aff;
    --primary-glow: rgba(0, 122, 255, 0.22);
    --primary-gradient: linear-gradient(180deg, #2b8cff 0%, #006be0 100%);
    --accent-gold: #c77c00;
    --secondary: #1f9d45;
    --secondary-glow: rgba(52, 199, 89, 0.22);
    --danger: #e0352b;
    --danger-glow: rgba(255, 59, 48, 0.2);
    --warning: #c76a00;
    --text-main: #1d1d1f;
    --text-muted: rgba(60, 60, 67, 0.7);
    --text-inverse: #ffffff;
    --glass-border-bright: 1px solid rgba(255, 255, 255, 0.95);
    --input-bg: rgba(255, 255, 255, 0.6);
    --input-border: 1px solid rgba(60, 60, 67, 0.14);
    --input-focus-bg: rgba(255, 255, 255, 0.85);
    --table-row-hover: rgba(255, 255, 255, 0.5);
    --table-border: 1px solid rgba(60, 60, 67, 0.09);
    --menu-hover-bg: rgba(0, 122, 255, 0.12);
    --menu-hover-text: #007aff;
    --shadow-lg: var(--lg-specular), 0 30px 70px -24px rgba(30, 45, 90, 0.35);
    --ring: 0 0 0 4px rgba(0, 122, 255, 0.22);
}

/* ---------- 2. Wallpaper ---------- */

html[data-skin="liquid"] body {
    font-family: var(--lg-font);
    background: var(--lg-base);
    background-image: none;
    color: var(--text-main);
    letter-spacing: -0.012em;
}

/* Soft colour fields that drift very slowly (transform-only → GPU cheap). */
html[data-skin="liquid"] body::before,
html[data-skin="liquid"] body::after {
    content: "";
    position: fixed;
    inset: -20vmax;
    z-index: -1;
    pointer-events: none;
    will-change: transform;
}

html[data-skin="liquid"] body::before {
    background:
        radial-gradient(40vmax 40vmax at 30% 32%, var(--lg-blob-1), transparent 70%),
        radial-gradient(36vmax 36vmax at 72% 30%, var(--lg-blob-2), transparent 70%),
        radial-gradient(42vmax 42vmax at 62% 72%, var(--lg-blob-3), transparent 70%);
    animation: lg-drift-a 38s ease-in-out infinite alternate;
}

html[data-skin="liquid"] body::after {
    background:
        radial-gradient(32vmax 32vmax at 34% 70%, var(--lg-blob-4), transparent 70%),
        radial-gradient(28vmax 28vmax at 52% 48%, var(--lg-blob-2), transparent 72%);
    opacity: 0.75;
    animation: lg-drift-b 46s ease-in-out infinite alternate;
}

@keyframes lg-drift-a {
    from { transform: translate3d(0, 0, 0) rotate(0deg); }
    to   { transform: translate3d(4vmax, -3vmax, 0) rotate(8deg); }
}

@keyframes lg-drift-b {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(-5vmax, 3vmax, 0) scale(1.12); }
}

html[data-skin="liquid"] h1,
html[data-skin="liquid"] h2,
html[data-skin="liquid"] h3,
html[data-skin="liquid"] h4 {
    font-family: var(--lg-font);
    letter-spacing: -0.025em;
    font-weight: 700;
}

html[data-skin="liquid"] ::selection {
    background: rgba(10, 132, 255, 0.35);
}

/* ---------- 3. Glass material (shared) ---------- */

html[data-skin="liquid"] :is(
    .card, .table-container, .liquid-card, .slds-card, .glass-card, .sale-form-card,
    .toolbar-glass, .admin-toolbar-glass, .tickets-container, .customer-card,
    .kpi-card, .kpi-card-new, .stat-card-new, .stat-card-neon, .summary-card-glass,
    .score-card, .report-card, .kb-card, .chart-box, .filter-card-modern, .details-box,
    .info-bar, .lightning-header, .profit-header, .sale-header, .notes-container,
    .task-container, .proc-container, .proc-section, .pending-emails-container, .pe-card,
    .cat-form-card, .ticket-fluid-card, .pl-stats, .pl-col, .kanban-column, .att-filter,
    .att-stats > div, .modal-card, .sw-card, .ops-card
) {
    background: var(--card-bg);
    backdrop-filter: var(--lg-blur);
    -webkit-backdrop-filter: var(--lg-blur);
    border: var(--glass-border);
    box-shadow: var(--shadow-md);
}

html[data-skin="liquid"] :is(.card, .table-container, .liquid-card, .slds-card, .glass-card,
    .sale-form-card, .customer-card, .kpi-card, .report-card, .kb-card, .chart-box,
    .score-card, .summary-card-glass, .details-box, .cat-form-card, .ticket-fluid-card) {
    border-radius: var(--radius-lg);
}

/* iOS barely lifts things on hover — a gentle brighten instead of a jump. */
html[data-skin="liquid"] :is(.card, .table-container, .liquid-card, .customer-card, .kb-card,
    .report-card, .score-card):hover {
    transform: translateY(-2px);
    background: var(--lg-glass-hover);
    border-color: rgba(255, 255, 255, 0.24);
    box-shadow: var(--shadow-lg);
}

html[data-skin="liquid"][data-theme="light"] :is(.card, .table-container, .liquid-card,
    .customer-card, .kb-card, .report-card, .score-card):hover {
    border-color: rgba(255, 255, 255, 1);
}

/* Glass inside glass (nested cards, kanban cards, rows) — lighter, no extra blur. */
html[data-skin="liquid"] :is(.kanban-card, .task-card, .pl-card, .activity-content, .ticket-row,
    .sale-row, .att-row, .report-row, .sum-row, .csat-row, .pl-mini) {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
}

html[data-skin="liquid"][data-theme="light"] :is(.kanban-card, .task-card, .pl-card, .activity-content,
    .ticket-row, .sale-row, .att-row, .report-row, .sum-row, .csat-row, .pl-mini) {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: inset 0 1px 0 #fff, 0 4px 14px -8px rgba(30, 45, 90, 0.2);
}

/* ---------- 4. Shell: floating glass sidebar ---------- */

html[data-skin="liquid"] .sidebar {
    background: var(--sidebar-bg);
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border);
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    top: 16px;
    right: 16px;
    height: calc(100vh - 32px);
    width: 272px;
    padding: 18px 14px;
    scrollbar-width: none;
}

html[data-skin="liquid"] .sidebar::-webkit-scrollbar { display: none; }

html[data-skin="liquid"] .brand {
    margin-bottom: 16px;
    padding-bottom: 16px;
}

html[data-skin="liquid"] .brand::after {
    background: linear-gradient(90deg, transparent, var(--lg-rim), transparent);
}

html[data-skin="liquid"] .brand img {
    width: 84px;
    height: 84px;
    border: 1px solid var(--lg-rim);
    box-shadow: var(--lg-specular), 0 12px 30px -10px rgba(0, 0, 0, 0.55);
}

html[data-skin="liquid"] .brand:hover img {
    transform: scale(1.04);
    box-shadow: var(--lg-specular), 0 14px 34px -10px rgba(0, 0, 0, 0.6);
}

html[data-skin="liquid"] .global-search-input {
    border-radius: 999px;
    background: var(--lg-fill);
    border: 1px solid transparent;
    padding: 10px 16px;
}

html[data-skin="liquid"] .global-search-input:focus {
    background: var(--input-focus-bg);
    border-color: var(--primary);
    box-shadow: var(--ring);
}

html[data-skin="liquid"] .global-search-results {
    background: var(--modal-bg);
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
}

html[data-skin="liquid"] .gs-item { border-radius: 14px; }

html[data-skin="liquid"] .nav-section-label {
    padding: 14px 16px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.8;
}

html[data-skin="liquid"] .nav-item { margin-bottom: 2px; }

html[data-skin="liquid"] .nav-link {
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.94rem;
    border: 1px solid transparent;
    transition: background 0.3s var(--lg-spring), transform 0.3s var(--lg-spring), color 0.2s;
}

html[data-skin="liquid"] .nav-link svg {
    color: var(--primary);
    opacity: 1;
}

html[data-skin="liquid"] .nav-link:hover {
    background: var(--lg-fill);
    color: var(--text-main);
    transform: none;
    border-color: transparent;
}

/* Active item = a tinted "lens" capsule, like the iOS 26 tab bar selection. */
html[data-skin="liquid"] .nav-link.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
    color: var(--text-main);
    font-weight: 600;
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: var(--lg-specular), 0 6px 18px -8px rgba(0, 0, 0, 0.5);
}

html[data-skin="liquid"][data-theme="light"] .nav-link.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
    border-color: #fff;
    box-shadow: var(--lg-specular), 0 6px 18px -8px rgba(30, 45, 90, 0.3);
}

/* Old per-link colour hacks (inline yellow/green) → consistent label colour. */
html[data-skin="liquid"] .nav-menu .nav-link[style] { color: var(--text-main) !important; }
html[data-skin="liquid"] .nav-menu .nav-section-label[style] { border-top-color: var(--lg-rim) !important; }

html[data-skin="liquid"] .user-panel {
    background: var(--lg-fill);
    border: 1px solid var(--lg-rim);
    border-radius: 24px;
    box-shadow: var(--lg-specular);
    padding: 16px;
}

html[data-skin="liquid"] .clock-btn {
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 16px -8px rgba(0, 0, 0, 0.5);
}

html[data-skin="liquid"] .clock-btn.out { background: linear-gradient(180deg, #34d167, #1fae4b); }
html[data-skin="liquid"] .clock-btn.in { background: linear-gradient(180deg, #ff5a4f, #e0352b); }

html[data-skin="liquid"] .main-content {
    margin-right: 304px;
    width: calc(100% - 304px);
    padding: 32px 36px;
    /* Opacity only: a transform (even a finished, filled one) on .main-content
       makes it the containing block for position:fixed, so every modal inside
       was centred on the whole long page instead of the screen — the close-ticket
       box opened far below the fold. */
    animation: lg-fade 0.55s var(--lg-spring) backwards;
}

/* `backwards`, not `both`: once the rise finishes the transform is dropped, so
   fixed-position popups nested in a section still position on the viewport. */
html[data-skin="liquid"] .main-content > * {
    animation: lg-rise 0.55s var(--lg-spring) backwards;
}

@keyframes lg-rise {
    from { opacity: 0; transform: translateY(10px) scale(0.995); }
    to { opacity: 1; transform: none; }
}

@keyframes lg-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---------- 5. Controls ---------- */

/* Primary buttons: filled capsule with a glossy top edge. */
html[data-skin="liquid"] :is(.btn-new, .btn-primary, .btn-slds-brand, .btn-primary-glow, .btn-success-solid) {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 8px 20px -10px var(--primary-glow);
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: transform 0.3s var(--lg-spring), filter 0.2s, box-shadow 0.3s;
}

html[data-skin="liquid"] :is(.btn-new, .btn-primary, .btn-slds-brand, .btn-primary-glow) {
    background: var(--primary-gradient);
    color: #fff;
}

html[data-skin="liquid"] :is(.btn-new, .btn-primary, .btn-slds-brand, .btn-primary-glow, .btn-success-solid):hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 12px 26px -10px var(--primary-glow);
}

html[data-skin="liquid"] :is(.btn-new, .btn-primary, .btn-slds-brand, .btn-primary-glow, .btn-success-solid, .btn-icon, .btn-slds, .btn-action, .action-btn, .btn-secondary, .quick-btn, .btn-custom):active {
    transform: scale(0.96);
}

/* Secondary buttons: clear glass capsule. */
html[data-skin="liquid"] :is(.btn-slds, .btn-secondary, .btn-custom, .quick-btn, .tab-btn) {
    border-radius: 999px;
    background: var(--lg-fill);
    border: 1px solid var(--lg-rim);
    color: var(--text-main);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html[data-skin="liquid"] :is(.btn-slds, .btn-secondary, .btn-custom, .quick-btn, .tab-btn):hover {
    background: var(--lg-glass-hover);
}

html[data-skin="liquid"] :is(.tab-btn.active) {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
}

html[data-skin="liquid"] :is(.btn-icon, .btn-action, .action-btn) {
    border-radius: 999px;
}

html[data-skin="liquid"] .btn-danger {
    background: linear-gradient(180deg, #ff5a4f, #e0352b);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Text inputs: soft filled fields, iOS-style. Element-level rules stay below
   inline-style specificity so any per-field inline look still wins. */
html[data-skin="liquid"] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]), select, textarea) {
    font-family: inherit;
    border-radius: 14px;
}

html[data-skin="liquid"] :is(.styled-input, .form-input, .sidebar-input, .sidebar-select, .ops-input,
    .filter-select, .styled-select-dark, .table-input, .cat-styled-input, .search-input, .styled-date-input) {
    background: var(--input-bg);
    border: var(--input-border);
    border-radius: 14px;
    color: var(--text-main);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

html[data-skin="liquid"] :is(input, select, textarea):focus {
    border-color: var(--primary);
    box-shadow: var(--ring);
    outline: none;
}

html[data-skin="liquid"] input[type=checkbox],
html[data-skin="liquid"] input[type=radio] {
    accent-color: var(--primary);
}

html[data-skin="liquid"] select option {
    background: #1c1e28;
    color: #f5f5f7;
}

html[data-skin="liquid"][data-theme="light"] select option {
    background: #fff;
    color: #1d1d1f;
}

/* Tom Select (smart search) */
html[data-skin="liquid"] .ts-control {
    border-radius: 14px !important;
    background: var(--input-bg) !important;
}

html[data-skin="liquid"] .ts-dropdown {
    background: var(--modal-bg) !important;
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border) !important;
    border-radius: 18px !important;
    overflow: hidden;
    padding: 4px;
}

html[data-skin="liquid"] .ts-dropdown .option { border-radius: 12px; }

/* Lists that pop over content need to stay readable — near-opaque glass. */
html[data-skin="liquid"] :is(.ts-dropdown, .global-search-results) {
    background: rgba(30, 32, 44, 0.94) !important;
}

html[data-skin="liquid"][data-theme="light"] :is(.ts-dropdown, .global-search-results) {
    background: rgba(250, 250, 253, 0.96) !important;
}

html[data-skin="liquid"] .ts-dropdown .active {
    background: var(--primary) !important;
    color: #fff !important;
}

/* Badges / pills */
html[data-skin="liquid"] :is(.badge, .n-pill, .ops-badge, .status-badge, .pill) {
    border-radius: 999px;
}

/* ---------- 6. Tables ---------- */

html[data-skin="liquid"] table { border-collapse: separate; border-spacing: 0; }

html[data-skin="liquid"] .main-content th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0;
    border-bottom: var(--table-border);
}

html[data-skin="liquid"] .main-content td {
    border-bottom: var(--table-border);
}

html[data-skin="liquid"] .main-content tbody tr {
    transition: background 0.2s;
}

html[data-skin="liquid"] .main-content tbody tr:hover {
    background: var(--table-row-hover);
}

html[data-skin="liquid"] .main-content tbody tr:last-child td { border-bottom: 0; }

/* ---------- 7. Overlays: modals, dialogs, toasts, dropdown menus ---------- */

html[data-skin="liquid"] .modal-overlay,
html[data-skin="liquid"] .pl-modal-bg {
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
}

html[data-skin="liquid"][data-theme="light"] .modal-overlay,
html[data-skin="liquid"][data-theme="light"] .pl-modal-bg {
    background: rgba(40, 50, 80, 0.18);
}

html[data-skin="liquid"] :is(.modal-content, .modal-box) {
    background: var(--modal-bg);
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border-bright);
    border-radius: 32px;
    box-shadow: var(--shadow-lg);
    animation: lg-pop 0.45s var(--lg-spring) both;
}

@keyframes lg-pop {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to { opacity: 1; transform: none; }
}

html[data-skin="liquid"] .adv-tools-menu,
html[data-skin="liquid"] .items-tooltip,
html[data-skin="liquid"] .fc-popover {
    background: var(--modal-bg) !important;
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border) !important;
    border-radius: 18px !important;
    box-shadow: var(--shadow-lg) !important;
}

/* Toasts are styled inline by showToast(); !important re-skins them as iOS banners. */
html[data-skin="liquid"] .toast-item {
    background: var(--modal-bg) !important;
    backdrop-filter: var(--lg-blur-strong) !important;
    -webkit-backdrop-filter: var(--lg-blur-strong) !important;
    border: var(--glass-border-bright) !important;
    border-radius: 24px !important;
    box-shadow: var(--shadow-lg) !important;
    animation: lg-pop 0.45s var(--lg-spring) both !important;
}

html[data-skin="liquid"] .flash-msg {
    background: var(--card-bg);
    backdrop-filter: var(--lg-blur);
    -webkit-backdrop-filter: var(--lg-blur);
    border-radius: 22px;
    box-shadow: var(--shadow-md);
}

html[data-skin="liquid"] .flash-success { border: 1px solid rgba(48, 209, 88, 0.45); }
html[data-skin="liquid"] .flash-danger { border: 1px solid rgba(255, 69, 58, 0.45); }

html[data-skin="liquid"] #missingPunchAlert {
    border-radius: 24px !important;
    background: linear-gradient(180deg, rgba(255, 90, 79, 0.88), rgba(224, 53, 43, 0.88)) !important;
    backdrop-filter: var(--lg-blur);
    -webkit-backdrop-filter: var(--lg-blur);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 14px 34px -14px rgba(224, 53, 43, 0.7) !important;
}

/* ---------- 8. Floating controls (theme button, mobile toggles) ---------- */

html[data-skin="liquid"] :is(.theme-fab-main, .mobile-nav-toggle) {
    background: var(--sidebar-bg);
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border);
    color: var(--text-main);
    box-shadow: var(--shadow-md);
}

html[data-skin="liquid"] .theme-fab-main { border-radius: 50%; }
html[data-skin="liquid"] .theme-fab-main:hover { transform: scale(1.08); }
html[data-skin="liquid"] .mobile-nav-toggle { border-radius: 50%; }

html[data-skin="liquid"] .theme-menu {
    padding: 8px;
    border-radius: 24px;
    background: var(--modal-bg);
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border);
    box-shadow: var(--shadow-lg);
}

/* ---------- 9. Scrollbars ---------- */

html[data-skin="liquid"] ::-webkit-scrollbar-thumb {
    background: rgba(160, 160, 175, 0.35);
    border: 3px solid transparent;
    background-clip: padding-box;
}

/* ---------- 10. Phones & tablets ---------- */

@media (max-width: 992px) {
    html[data-skin="liquid"] .main-content {
        margin-right: 0;
        width: 100%;
        padding: 76px 14px calc(110px + env(safe-area-inset-bottom, 0px));
    }

    html[data-skin="liquid"] .sidebar {
        top: 10px;
        right: 10px;
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
    }

    /* iOS 26 floating tab bar: a detached glass capsule above the home bar. */
    html[data-skin="liquid"] .mobile-bottom-nav {
        left: 14px;
        right: 14px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding: 6px;
        border-radius: 999px;
        background: var(--sidebar-bg);
        backdrop-filter: var(--lg-blur-strong);
        -webkit-backdrop-filter: var(--lg-blur-strong);
        border: var(--glass-border);
        box-shadow: var(--shadow-lg);
    }

    html[data-skin="liquid"] .mobile-bottom-nav .mbn-item {
        border-radius: 999px;
        color: var(--text-main);
        font-size: 0.68rem;
        font-weight: 500;
        transition: background 0.35s var(--lg-spring), transform 0.35s var(--lg-spring);
    }

    html[data-skin="liquid"] .mobile-bottom-nav .mbn-item.active {
        color: var(--primary);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.07));
        box-shadow: var(--lg-specular);
    }

    html[data-skin="liquid"][data-theme="light"] .mobile-bottom-nav .mbn-item.active {
        background: rgba(255, 255, 255, 0.85);
    }

    html[data-skin="liquid"] .mobile-nav-toggle {
        top: 14px;
        right: 14px;
    }

    /* Theme button would float over content / the tab bar — park it in the
       top-left corner, mirroring the menu button, and open its menu downward. */
    html[data-skin="liquid"] .theme-fab-container {
        top: 14px;
        bottom: auto;
        left: 14px;
        flex-direction: column;
    }

    html[data-skin="liquid"] .theme-fab-main {
        width: 48px;
        height: 48px;
    }

    html[data-skin="liquid"] .theme-menu {
        margin: 10px 0 0;
        transform: translateY(-12px) scale(0.9);
    }

    html[data-skin="liquid"] .theme-menu.active { transform: none; }
}

@media (max-width: 600px) {
    html[data-skin="liquid"] :is(.card, .table-container, .liquid-card, .slds-card, .glass-card) {
        border-radius: 22px;
    }
}

/* ---------- 11. Accessibility & fallbacks ---------- */

@media (prefers-reduced-motion: reduce) {
    html[data-skin="liquid"] body::before,
    html[data-skin="liquid"] body::after { animation: none; }
}

/* Users who asked the OS for less transparency get near-opaque surfaces. */
@media (prefers-reduced-transparency: reduce) {
    html[data-skin="liquid"] { --card-bg: rgba(28, 30, 40, 0.94); --sidebar-bg: rgba(22, 24, 34, 0.96); }
    html[data-skin="liquid"][data-theme="light"] { --card-bg: rgba(255, 255, 255, 0.95); --sidebar-bg: rgba(255, 255, 255, 0.96); }
}

/* Browsers without backdrop-filter: keep text readable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    html[data-skin="liquid"] { --card-bg: rgba(28, 30, 40, 0.92); --sidebar-bg: rgba(22, 24, 34, 0.95); }
    html[data-skin="liquid"][data-theme="light"] { --card-bg: rgba(255, 255, 255, 0.92); --sidebar-bg: rgba(255, 255, 255, 0.95); }
}

@media print {
    html[data-skin="liquid"] body::before,
    html[data-skin="liquid"] body::after { display: none; }
    html[data-skin="liquid"] body { background: #fff; color: #000; }
}

/* ---------- 12. Login page (templates/login.html, body.lg-login) ---------- */

/* Reset login.html's own absolutely-positioned aurora blobs to the wallpaper. */
html[data-skin="liquid"] body.lg-login::before,
html[data-skin="liquid"] body.lg-login::after {
    position: fixed;
    inset: -20vmax;
    width: auto;
    height: auto;
    border-radius: 0;
    filter: none;
    top: -20vmax;
    right: -20vmax;
    bottom: -20vmax;
    left: -20vmax;
}

html[data-skin="liquid"] body.lg-login::before { opacity: 1; }

html[data-skin="liquid"] .login-card {
    background: var(--sidebar-bg);
    backdrop-filter: var(--lg-blur-strong);
    -webkit-backdrop-filter: var(--lg-blur-strong);
    border: var(--glass-border);
    border-radius: 36px;
    box-shadow: var(--shadow-lg);
    animation: lg-pop 0.6s var(--lg-spring) both;
}

html[data-skin="liquid"] .login-card h2 { color: var(--text-main); }
html[data-skin="liquid"] .login-card label,
html[data-skin="liquid"] .login-card .sub-text,
html[data-skin="liquid"] .login-card .footer-text { color: var(--text-muted); }

html[data-skin="liquid"] .login-logo {
    width: 96px;
    height: 96px;
    border: 1px solid var(--lg-rim);
    box-shadow: var(--lg-specular), 0 14px 34px -12px rgba(0, 0, 0, 0.55);
}

html[data-skin="liquid"] .login-card .accent-line { background: var(--primary-gradient); }

html[data-skin="liquid"] .login-card input {
    background: var(--lg-fill);
    border: 1px solid transparent;
    color: var(--text-main);
}

html[data-skin="liquid"] .login-card input::placeholder { color: var(--text-muted); }

html[data-skin="liquid"] .login-card input:focus {
    background: var(--input-focus-bg);
    border-color: var(--primary);
    box-shadow: var(--ring);
}

html[data-skin="liquid"] .btn-submit {
    background: var(--primary-gradient);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 12px 26px -10px var(--primary-glow);
}

/* Links styled as buttons never get the default underline. */
html[data-skin="liquid"] a:is(.btn-new, .btn-primary, .btn-slds, .btn-slds-brand, .btn-primary-glow,
    .btn-success-solid, .btn-secondary, .btn-custom, .quick-btn, .btn-action, .action-btn, .btn-icon, .btn) {
    text-decoration: none;
}

/* Many templates hard-code dark inline field backgrounds (rgba(0,0,0,.2) etc.)
   that turn into grey slabs in the light theme — re-skin them as light fields. */
html[data-skin="liquid"][data-theme="light"] :is(input, select, textarea):is(
    [style*="background:rgba(0,0,0"], [style*="background: rgba(0,0,0"],
    [style*="background: rgba(0, 0, 0"], [style*="background:rgba(0, 0, 0"],
    [style*="background:#0"], [style*="background: #0"], [style*="background:#1"], [style*="background: #1"]) {
    background: var(--input-bg) !important;
    border: var(--input-border) !important;
    color: var(--text-main) !important;
}

/* Desktop: the floating palette button covered page content in the bottom-left
   corner — it lives in the sidebar's user panel ("🎨 מראה ועיצוב") instead, and
   its menu pops out beside the sidebar. */
@media (min-width: 993px) {
    html[data-skin="liquid"] .theme-fab-main { display: none; }

    html[data-skin="liquid"] .theme-fab-container {
        left: auto;
        right: 304px;
        bottom: 24px;
    }

    html[data-skin="liquid"] .theme-menu { margin-bottom: 0; }
}
