/*
 * Design System Utilities
 * ======================
 * Bridge layer: maps design tokens to semantic CSS classes.
 * Use these classes instead of inline styles in Blade templates.
 *
 * Token source: resources/views/layouts/partials/design-tokens.blade.php
 * Dependencies: design-tokens must load before this file.
 *
 * Naming: .ds-{category}-{variant}
 *   .ds-card        — surface card with border, radius, shadow
 *   .ds-badge-*     — status badges (success, danger, warning, info, muted)
 *   .ds-icon-badge  — 48px icon container (setup wizards, dashboards)
 *   .ds-section     — content section with padding + border-bottom
 *   .ds-text-*      — semantic text styles
 *   .ds-bg-*        — semantic background fills
 */

/* ==========================================================================
   CARDS — Replace inline: background:#fff; border-radius:12px; border:1px solid #e5e7eb; box-shadow:...
   143+ occurrences across templates
   ========================================================================== */

.ds-card {
    background: var(--app-color-surface-elevated, #fff);
    border: 1px solid var(--app-color-border, #e5e7eb);
    border-radius: var(--ds-radius-lg, 0.75rem);
    box-shadow: var(--ds-shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
    overflow: hidden;
}

.ds-card-hover {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ds-card-hover:hover {
    box-shadow: var(--ds-shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
}

/* Card padding variants */
.ds-card-body {
    padding: var(--ds-spacing-4, 1rem);
}

.ds-card-body-lg {
    padding: var(--ds-spacing-6, 1.5rem);
}

.ds-card-body-sm {
    padding: var(--ds-spacing-3, 0.75rem);
}

/* Card header — icon + title + optional actions */
.ds-card-header {
    display: flex;
    align-items: center;
    gap: var(--ds-spacing-3, 0.75rem);
    padding: var(--ds-spacing-4, 1rem);
    border-bottom: 1px solid var(--app-color-border, #e5e7eb);
    font-weight: var(--ds-font-weight-semibold, 600);
    font-size: var(--ds-font-size-base, 1rem);
    color: var(--app-color-text-primary, #111827);
}

.ds-card-header .ds-card-actions {
    margin-inline-start: auto;
}

/* Card footer */
.ds-card-footer {
    padding: var(--ds-spacing-3, 0.75rem) var(--ds-spacing-4, 1rem);
    border-top: 1px solid var(--app-color-border, #e5e7eb);
    background: var(--app-color-surface, #f9fafb);
}


/* ==========================================================================
   STATUS BADGES — Replace inline: padding:3px 10px; border-radius:12px; background:#d1fae5; color:#065f46;
   123 occurrences across 39 files
   ========================================================================== */

.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.625rem;
    border-radius: var(--ds-radius-full, 9999px);
    font-size: var(--ds-font-size-xs, 0.75rem);
    font-weight: var(--ds-font-weight-medium, 500);
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: middle;
}

.ds-badge-success {
    background: #dcfce7;
    color: #166534;
}

.ds-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.ds-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.ds-badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.ds-badge-muted {
    background: var(--ds-color-gray-100, #f3f4f6);
    color: var(--ds-color-gray-600, #4b5563);
}

.ds-badge-primary {
    background: #e0e7ff;
    color: #3730a3;
}

/* Dot indicator variant: small colored dot before text */
.ds-badge-dot::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ds-badge-success.ds-badge-dot::before { background: #16a34a; }
.ds-badge-danger.ds-badge-dot::before  { background: #dc2626; }
.ds-badge-warning.ds-badge-dot::before { background: #d97706; }
.ds-badge-info.ds-badge-dot::before    { background: #2563eb; }
.ds-badge-muted.ds-badge-dot::before   { background: #9ca3af; }
.ds-badge-primary.ds-badge-dot::before { background: #4f46e5; }


/* ==========================================================================
   ICON BADGES — Replace inline: width:48px; height:48px; border-radius:12px; display:flex;
                  align-items:center; justify-content:center; font-size:18px;
   9+ identical patterns in setup wizards, dashboards
   ========================================================================== */

.ds-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    border-radius: var(--ds-radius-lg, 0.75rem);
    font-size: 1.125rem;
    font-weight: var(--ds-font-weight-bold, 700);
    flex-shrink: 0;
}

.ds-icon-badge-sm {
    width: 36px;
    min-width: 36px;
    height: 36px;
    font-size: 0.875rem;
    border-radius: var(--ds-radius-md, 0.5rem);
}

.ds-icon-badge-lg {
    width: 56px;
    min-width: 56px;
    height: 56px;
    font-size: 1.375rem;
    border-radius: var(--ds-radius-xl, 1rem);
}

/* Semantic color fills for icon badges */
.ds-icon-badge-success { background: #dcfce7; color: #166534; }
.ds-icon-badge-danger  { background: #fee2e2; color: #991b1b; }
.ds-icon-badge-warning { background: #fef3c7; color: #92400e; }
.ds-icon-badge-info    { background: #dbeafe; color: #1e40af; }
.ds-icon-badge-primary { background: #e0e7ff; color: #3730a3; }
.ds-icon-badge-muted   { background: var(--ds-color-gray-100, #f3f4f6); color: var(--ds-color-gray-600, #4b5563); }
.ds-icon-badge-purple  { background: #f3e8ff; color: #6b21a8; }


/* ==========================================================================
   SECTION CARDS — For grouped content areas (settings, form sections)
   iPhone-Settings-style grouped sections
   ========================================================================== */

.ds-section {
    background: var(--app-color-surface-elevated, #fff);
    border: 1px solid var(--app-color-border, #e5e7eb);
    border-radius: var(--ds-radius-lg, 0.75rem);
    overflow: hidden;
}

.ds-section-header {
    padding: var(--ds-spacing-3, 0.75rem) var(--ds-spacing-4, 1rem);
    font-size: var(--ds-font-size-sm, 0.875rem);
    font-weight: var(--ds-font-weight-semibold, 600);
    color: var(--app-color-text-secondary, #4b5563);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    background: var(--app-color-surface, #f9fafb);
    border-bottom: 1px solid var(--app-color-border, #e5e7eb);
}

.ds-section-row {
    display: flex;
    align-items: center;
    gap: var(--ds-spacing-3, 0.75rem);
    padding: var(--ds-spacing-3, 0.75rem) var(--ds-spacing-4, 1rem);
    border-bottom: 1px solid var(--ds-color-gray-100, #f3f4f6);
    min-height: 44px; /* WCAG touch target */
}

.ds-section-row:last-child {
    border-bottom: none;
}

.ds-section-row-label {
    flex: 1;
    font-size: var(--ds-font-size-sm, 0.875rem);
    color: var(--app-color-text-primary, #111827);
}

.ds-section-row-value {
    font-size: var(--ds-font-size-sm, 0.875rem);
    color: var(--app-color-text-secondary, #4b5563);
}


/* ==========================================================================
   STAT CARDS — KPI / metric display (dashboards, reports)
   ========================================================================== */

.ds-stat {
    display: flex;
    align-items: center;
    gap: var(--ds-spacing-4, 1rem);
    padding: var(--ds-spacing-4, 1rem) var(--ds-spacing-6, 1.5rem);
}

.ds-stat-value {
    font-size: var(--ds-font-size-2xl, 1.5rem);
    font-weight: var(--ds-font-weight-bold, 700);
    color: var(--app-color-text-primary, #111827);
    line-height: var(--ds-line-height-tight, 1.25);
}

.ds-stat-label {
    font-size: var(--ds-font-size-sm, 0.875rem);
    color: var(--app-color-text-secondary, #4b5563);
    font-weight: var(--ds-font-weight-medium, 500);
}

.ds-stat-change {
    font-size: var(--ds-font-size-xs, 0.75rem);
    font-weight: var(--ds-font-weight-medium, 500);
}

.ds-stat-change-up   { color: #16a34a; }
.ds-stat-change-down { color: #dc2626; }


/* ==========================================================================
   TEXT UTILITIES — Semantic text colors mapped to tokens
   ========================================================================== */

.ds-text-primary   { color: var(--app-color-text-primary, #111827) !important; }
.ds-text-secondary { color: var(--app-color-text-secondary, #4b5563) !important; }
.ds-text-muted     { color: var(--app-color-text-tertiary, #6b7280) !important; }
.ds-text-success   { color: var(--ds-color-success-700, #067647) !important; }
.ds-text-danger    { color: var(--ds-color-danger-700, #b42318) !important; }
.ds-text-warning   { color: var(--ds-color-warning-700, #b54708) !important; }
.ds-text-info      { color: var(--ds-color-info-700, #026aa2) !important; }

/* Font sizes */
.ds-text-xs   { font-size: var(--ds-font-size-xs, 0.75rem) !important; }
.ds-text-sm   { font-size: var(--ds-font-size-sm, 0.875rem) !important; }
.ds-text-base { font-size: var(--ds-font-size-base, 1rem) !important; }
.ds-text-lg   { font-size: var(--ds-font-size-lg, 1.125rem) !important; }
.ds-text-xl   { font-size: var(--ds-font-size-xl, 1.25rem) !important; }
.ds-text-2xl  { font-size: var(--ds-font-size-2xl, 1.5rem) !important; }

/* Font weights */
.ds-font-normal   { font-weight: var(--ds-font-weight-normal, 400) !important; }
.ds-font-medium   { font-weight: var(--ds-font-weight-medium, 500) !important; }
.ds-font-semibold { font-weight: var(--ds-font-weight-semibold, 600) !important; }
.ds-font-bold     { font-weight: var(--ds-font-weight-bold, 700) !important; }


/* ==========================================================================
   BACKGROUND UTILITIES — Semantic surface colors
   ========================================================================== */

.ds-bg-surface  { background-color: var(--app-color-surface, #f9fafb) !important; }
.ds-bg-white    { background-color: var(--app-color-surface-elevated, #fff) !important; }
.ds-bg-success  { background-color: #dcfce7 !important; }
.ds-bg-danger   { background-color: #fee2e2 !important; }
.ds-bg-warning  { background-color: #fef3c7 !important; }
.ds-bg-info     { background-color: #dbeafe !important; }
.ds-bg-muted    { background-color: var(--ds-color-gray-100, #f3f4f6) !important; }
.ds-bg-primary  { background-color: #e0e7ff !important; }


/* ==========================================================================
   BORDER UTILITIES — Common border patterns
   ========================================================================== */

.ds-border       { border: 1px solid var(--app-color-border, #e5e7eb) !important; }
.ds-border-b     { border-bottom: 1px solid var(--app-color-border, #e5e7eb) !important; }
.ds-border-t     { border-top: 1px solid var(--app-color-border, #e5e7eb) !important; }
.ds-border-light { border: 1px solid var(--ds-color-gray-100, #f3f4f6) !important; }

/* Border radius */
.ds-rounded-sm   { border-radius: var(--ds-radius-sm, 0.25rem) !important; }
.ds-rounded      { border-radius: var(--ds-radius-base, 0.375rem) !important; }
.ds-rounded-md   { border-radius: var(--ds-radius-md, 0.5rem) !important; }
.ds-rounded-lg   { border-radius: var(--ds-radius-lg, 0.75rem) !important; }
.ds-rounded-xl   { border-radius: var(--ds-radius-xl, 1rem) !important; }
.ds-rounded-full { border-radius: var(--ds-radius-full, 9999px) !important; }


/* ==========================================================================
   SHADOW UTILITIES
   ========================================================================== */

.ds-shadow-none { box-shadow: none !important; }
.ds-shadow-sm   { box-shadow: var(--ds-shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05)) !important; }
.ds-shadow      { box-shadow: var(--ds-shadow-base, 0 1px 3px 0 rgba(0, 0, 0, 0.1)) !important; }
.ds-shadow-md   { box-shadow: var(--ds-shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1)) !important; }
.ds-shadow-lg   { box-shadow: var(--ds-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1)) !important; }


/* ==========================================================================
   SPACING UTILITIES — Gap, padding, margin mapped to token scale
   ========================================================================== */

.ds-gap-1  { gap: var(--ds-spacing-1, 0.25rem) !important; }
.ds-gap-2  { gap: var(--ds-spacing-2, 0.5rem) !important; }
.ds-gap-3  { gap: var(--ds-spacing-3, 0.75rem) !important; }
.ds-gap-4  { gap: var(--ds-spacing-4, 1rem) !important; }
.ds-gap-6  { gap: var(--ds-spacing-6, 1.5rem) !important; }
.ds-gap-8  { gap: var(--ds-spacing-8, 2rem) !important; }

.ds-p-0  { padding: 0 !important; }
.ds-p-2  { padding: var(--ds-spacing-2, 0.5rem) !important; }
.ds-p-3  { padding: var(--ds-spacing-3, 0.75rem) !important; }
.ds-p-4  { padding: var(--ds-spacing-4, 1rem) !important; }
.ds-p-6  { padding: var(--ds-spacing-6, 1.5rem) !important; }
.ds-p-8  { padding: var(--ds-spacing-8, 2rem) !important; }

.ds-px-4 { padding-inline: var(--ds-spacing-4, 1rem) !important; }
.ds-px-6 { padding-inline: var(--ds-spacing-6, 1.5rem) !important; }
.ds-py-2 { padding-block: var(--ds-spacing-2, 0.5rem) !important; }
.ds-py-3 { padding-block: var(--ds-spacing-3, 0.75rem) !important; }
.ds-py-4 { padding-block: var(--ds-spacing-4, 1rem) !important; }

.ds-mb-4 { margin-bottom: var(--ds-spacing-4, 1rem) !important; }
.ds-mb-6 { margin-bottom: var(--ds-spacing-6, 1.5rem) !important; }
.ds-mt-4 { margin-top: var(--ds-spacing-4, 1rem) !important; }


/* ==========================================================================
   LAYOUT HELPERS
   ========================================================================== */

.ds-flex        { display: flex !important; }
.ds-flex-col    { display: flex !important; flex-direction: column !important; }
.ds-items-center { align-items: center !important; }
.ds-justify-between { justify-content: space-between !important; }

.ds-grid        { display: grid !important; }
.ds-grid-cards  { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important; gap: var(--ds-spacing-4, 1rem) !important; }
.ds-grid-stats  { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; gap: var(--ds-spacing-4, 1rem) !important; }


/* ==========================================================================
   EMPTY STATE — Consistent "no data" pattern
   ========================================================================== */

.ds-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--ds-spacing-12, 3rem) var(--ds-spacing-4, 1rem);
    text-align: center;
    color: var(--app-color-text-tertiary, #6b7280);
}

.ds-empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: var(--ds-spacing-4, 1rem);
    opacity: 0.5;
}

.ds-empty-state-title {
    font-size: var(--ds-font-size-base, 1rem);
    font-weight: var(--ds-font-weight-medium, 500);
    color: var(--app-color-text-secondary, #4b5563);
    margin: 0 0 var(--ds-spacing-2, 0.5rem);
}

.ds-empty-state-text {
    font-size: var(--ds-font-size-sm, 0.875rem);
    margin: 0 0 var(--ds-spacing-6, 1.5rem);
    max-width: 320px;
}


/* ==========================================================================
   WIZARD STEPS — Consistent step indicator pattern
   6+ different implementations across templates
   ========================================================================== */

.ds-wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--ds-spacing-2, 0.5rem);
    padding: var(--ds-spacing-4, 1rem) 0;
    margin-bottom: var(--ds-spacing-6, 1.5rem);
}

.ds-wizard-step {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-spacing-2, 0.5rem);
    padding: var(--ds-spacing-2, 0.5rem) var(--ds-spacing-4, 1rem);
    border-radius: var(--ds-radius-full, 9999px);
    font-size: var(--ds-font-size-sm, 0.875rem);
    font-weight: var(--ds-font-weight-medium, 500);
    background: var(--ds-color-gray-100, #f3f4f6);
    color: var(--ds-color-gray-500, #6b7280);
    cursor: default;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ds-wizard-step.active {
    background: #e0e7ff;
    color: #4338ca;
    font-weight: var(--ds-font-weight-semibold, 600);
}

.ds-wizard-step.done {
    background: #dcfce7;
    color: #166534;
    cursor: pointer;
}

.ds-wizard-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: var(--ds-font-size-xs, 0.75rem);
    font-weight: var(--ds-font-weight-bold, 700);
    background: rgba(0, 0, 0, 0.1);
}

.ds-wizard-step.active .ds-wizard-step-number {
    background: #4338ca;
    color: #fff;
}

.ds-wizard-step.done .ds-wizard-step-number {
    background: #16a34a;
    color: #fff;
}

.ds-wizard-connector {
    width: 32px;
    height: 2px;
    background: var(--ds-color-gray-200, #e5e7eb);
    flex-shrink: 0;
}

.ds-wizard-connector.done {
    background: #16a34a;
}


/* ==========================================================================
   KEBAB MENU — 3-dot action menu for cards
   ========================================================================== */

.ds-kebab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--ds-radius-md, 0.5rem);
    cursor: pointer;
    color: var(--ds-color-gray-400, #9ca3af);
    transition: all 0.15s ease;
    border: none;
    background: transparent;
    padding: 0;
}

.ds-kebab:hover {
    background: var(--ds-color-gray-100, #f3f4f6);
    color: var(--ds-color-gray-700, #374151);
}


/* ==========================================================================
   DARK MODE OVERRIDES
   ========================================================================== */

html[data-ui-theme="dark"] .ds-card,
html[data-ui-theme="dark"] .ds-section {
    background: #1f2937;
    border-color: rgba(255, 255, 255, 0.1);
}

html[data-ui-theme="dark"] .ds-card-header {
    border-color: rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
}

html[data-ui-theme="dark"] .ds-card-footer {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.1);
}

html[data-ui-theme="dark"] .ds-section-header {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

html[data-ui-theme="dark"] .ds-section-row {
    border-color: rgba(255, 255, 255, 0.06);
}

html[data-ui-theme="dark"] .ds-section-row-label { color: #e5e7eb; }
html[data-ui-theme="dark"] .ds-section-row-value { color: #9ca3af; }

html[data-ui-theme="dark"] .ds-stat-value { color: #e5e7eb; }
html[data-ui-theme="dark"] .ds-stat-label { color: #9ca3af; }

html[data-ui-theme="dark"] .ds-empty-state { color: #6b7280; }
html[data-ui-theme="dark"] .ds-empty-state-title { color: #9ca3af; }

html[data-ui-theme="dark"] .ds-wizard-step {
    background: #374151;
    color: #9ca3af;
}

html[data-ui-theme="dark"] .ds-wizard-step.active {
    background: #312e81;
    color: #a5b4fc;
}

html[data-ui-theme="dark"] .ds-wizard-step.done {
    background: #14532d;
    color: #86efac;
}

html[data-ui-theme="dark"] .ds-wizard-connector {
    background: #374151;
}

html[data-ui-theme="dark"] .ds-kebab:hover {
    background: #374151;
    color: #e5e7eb;
}

/* Dark mode badge variants */
html[data-ui-theme="dark"] .ds-badge-success { background: #14532d; color: #86efac; }
html[data-ui-theme="dark"] .ds-badge-danger  { background: #7f1d1d; color: #fca5a5; }
html[data-ui-theme="dark"] .ds-badge-warning { background: #78350f; color: #fcd34d; }
html[data-ui-theme="dark"] .ds-badge-info    { background: #1e3a5f; color: #93c5fd; }
html[data-ui-theme="dark"] .ds-badge-muted   { background: #374151; color: #9ca3af; }
html[data-ui-theme="dark"] .ds-badge-primary { background: #312e81; color: #a5b4fc; }

html[data-ui-theme="dark"] .ds-icon-badge-success { background: #14532d; color: #86efac; }
html[data-ui-theme="dark"] .ds-icon-badge-danger  { background: #7f1d1d; color: #fca5a5; }
html[data-ui-theme="dark"] .ds-icon-badge-warning { background: #78350f; color: #fcd34d; }
html[data-ui-theme="dark"] .ds-icon-badge-info    { background: #1e3a5f; color: #93c5fd; }
html[data-ui-theme="dark"] .ds-icon-badge-primary { background: #312e81; color: #a5b4fc; }
html[data-ui-theme="dark"] .ds-icon-badge-muted   { background: #374151; color: #9ca3af; }
html[data-ui-theme="dark"] .ds-icon-badge-purple  { background: #3b0764; color: #d8b4fe; }

/* Dark mode background utilities */
html[data-ui-theme="dark"] .ds-bg-surface  { background-color: #1f2937 !important; }
html[data-ui-theme="dark"] .ds-bg-white    { background-color: #1f2937 !important; }
html[data-ui-theme="dark"] .ds-bg-success  { background-color: #14532d !important; }
html[data-ui-theme="dark"] .ds-bg-danger   { background-color: #7f1d1d !important; }
html[data-ui-theme="dark"] .ds-bg-warning  { background-color: #78350f !important; }
html[data-ui-theme="dark"] .ds-bg-info     { background-color: #1e3a5f !important; }
html[data-ui-theme="dark"] .ds-bg-muted    { background-color: #374151 !important; }
html[data-ui-theme="dark"] .ds-bg-primary  { background-color: #312e81 !important; }

/* Dark mode empty state */
html[data-ui-theme="dark"] .ds-empty-state-icon { opacity: 0.4; }


/* ==========================================================================
   RTL ADJUSTMENTS
   ========================================================================== */

html[dir="rtl"] .ds-card-header .ds-card-actions {
    margin-inline-start: auto;
    margin-inline-end: 0;
}


/* **************************************************************************
 * RESPONSIVE ADAPTATION LAYER
 * Global responsive fixes that affect every page in the system.
 * ************************************************************************** */


/* ==========================================================================
   SIDEBAR — Mobile drawer fix
   The sidebar has inline style="display:flex" which breaks responsive hiding.
   JS already toggles .small-view-side-active + .overlay on hamburger click.
   This CSS makes it a proper off-canvas drawer on < 992px.
   ========================================================================== */

@media (max-width: 991px) {
    /* Hide sidebar by default on mobile/tablet — override inline style */
    .side-bar {
        display: none !important;
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px !important;
        max-width: 85vw;
        z-index: 1050;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
        transition: transform 0.25s ease;
    }

    /* When toggled open via JS */
    .side-bar.small-view-side-active {
        display: flex !important;
        flex-direction: column;
    }

    /* Overlay behind sidebar */
    .overlay {
        z-index: 1040 !important;
    }

    /* Give main content full width */
    .thetop > main {
        width: 100% !important;
    }
}

/* RTL sidebar: slide from right */
@media (max-width: 991px) {
    html[dir="rtl"] .side-bar {
        left: auto;
        right: 0;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    }
}


/* ==========================================================================
   MODALS — Responsive sizing
   modal-lg (900px) and modal-xl (1140px) are unusable on phones.
   Force them to near-full-width on small screens.
   ========================================================================== */

@media (max-width: 767px) {
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        width: calc(100vw - 20px) !important;
        max-width: none !important;
        margin: 10px auto !important;
    }

    /* Limit modal height so content scrolls instead of page */
    .modal-dialog.modal-lg .modal-body,
    .modal-dialog.modal-xl .modal-body {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Shrink modal header padding on mobile */
    .modal-header {
        padding: 12px 16px;
    }

    .modal-body {
        padding: 12px 16px;
    }

    .modal-footer {
        padding: 8px 16px;
    }

    /* Modal title smaller on mobile */
    .modal-title {
        font-size: 1rem;
    }
}

/* Tablet: modal-xl gets reduced to near-lg width */
@media (min-width: 768px) and (max-width: 991px) {
    .modal-dialog.modal-xl {
        width: calc(100vw - 40px) !important;
        max-width: 900px !important;
    }
}


/* ==========================================================================
   TOUCH TARGETS — 44px minimum for all interactive elements
   WCAG 2.1 AA / Apple HIG touch target requirement
   ========================================================================== */

/* Buttons: ensure minimum touch target */
.btn,
.ds-badge[onclick],
.ds-badge[role="button"],
a.ds-badge {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Exception: buttons inside DataTable rows and dense lists can be smaller */
.modern-dt-card .btn,
.table .btn,
.btn-group .btn {
    min-height: 36px;
    min-width: 36px;
}

/* btn-xs: increase to 36px minimum (was ~22px) */
.btn-xs {
    min-height: 36px !important;
    min-width: 36px !important;
    padding: 4px 10px !important;
    font-size: 12px !important;
}

/* Form controls: minimum height */
.form-control,
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
    min-height: 44px !important;
}

/* === Light mode form input fix (034) === */
html[data-ui-theme="light"] .form-control {
    background-color: #fff;
    color: #333;
    border-color: #d2d6de;
}
html[data-ui-theme="light"] .select2-container--default .select2-selection--single,
html[data-ui-theme="light"] .select2-container--default .select2-selection--multiple {
    background-color: #fff;
    color: #333;
    border-color: #d2d6de;
}

/* Dropdown menu items: 44px minimum touch target */
.dropdown-menu > li > a {
    padding: 10px 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* Sidebar links: touch-friendly spacing */
@media (max-width: 991px) {
    .side-bar .treeview-menu > li > a,
    .side-bar .sidebar-menu > li > a {
        padding: 12px 16px !important;
        min-height: 44px;
    }
}

/* Checkbox/radio: increase clickable area */
input[type="checkbox"],
input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
}


/* ==========================================================================
   TABLES — Make tables scrollable on mobile by default
   ========================================================================== */

@media (max-width: 767px) {
    /* Auto-wrap tables that aren't already in a responsive container */
    .box-body > .table,
    .ds-card-body > .table,
    .tab-content > .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* DataTable wrapper scrolls on mobile */
    .dataTables_wrapper {
        overflow-x: auto;
    }

    /* Reduce DataTable button text on mobile */
    .dt-buttons .btn {
        padding: 6px 8px !important;
        font-size: 11px !important;
    }

    /* Stack DataTable controls */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center !important;
        margin-bottom: 8px;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        margin-top: 8px;
    }
}


/* ==========================================================================
   FORMS — Column stacking on mobile
   ========================================================================== */

@media (max-width: 575px) {
    /* Force all Bootstrap columns to full-width on phones */
    .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6,
    .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}


/* ==========================================================================
   HEADER — Mobile compact
   ========================================================================== */

@media (max-width: 767px) {
    /* Compact header padding on mobile */
    .app-theme-header .tw-px-5 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Hide non-essential header items on mobile */
    .app-theme-header .tw-hidden.sm\:tw-flex {
        display: none !important;
    }
}


/* ==========================================================================
   GRID CARDS — Responsive minmax adjustments
   ========================================================================== */

@media (max-width: 480px) {
    .ds-grid-cards {
        grid-template-columns: 1fr !important;
    }

    .ds-grid-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 359px) {
    .ds-grid-stats {
        grid-template-columns: 1fr !important;
    }
}


/* ==========================================================================
   PRINT — Hide non-content elements
   ========================================================================== */

@media print {
    .side-bar,
    .app-theme-header,
    .overlay,
    .ds-kebab,
    .btn,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dt-buttons,
    .no-print {
        display: none !important;
    }

    .ds-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    #scrollable-container {
        overflow: visible !important;
        height: auto !important;
    }

    body, main {
        background: white !important;
    }
}


/* **************************************************************************
 * HARDENING LAYER
 * Production resilience: text overflow, reduced motion, RTL icons,
 * double-submit prevention, error recovery.
 * ************************************************************************** */


/* ==========================================================================
   TEXT OVERFLOW — Prevent Arabic (30-50% longer) from breaking layouts
   Affects: card titles, sidebar labels, table cells, KPI cards
   ========================================================================== */

/* Card titles: single-line truncate */
.box-title,
.ds-card-header,
.modal-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Sidebar menu labels: truncate within 256px sidebar */
.side-bar .sidebar-menu > li > a,
.side-bar .treeview-menu > li > a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar business name: truncate in header */
.side-bar .side-bar-heading {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

/* DataTable cells: prevent extremely long text from forcing horizontal scroll */
.table td {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Allow wrapping in specific columns that need it (descriptions, notes) */
.table td.wrap-text,
.table td[data-wrap] {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: none;
}

/* Flex item overflow prevention (critical for flex layouts) */
.ds-card-header,
.ds-section-row,
.ds-stat,
.ds-wizard-step {
    min-width: 0;
}

/* Multi-line text clamp (for card descriptions, product names in cards) */
.ds-line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ds-line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ds-line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Word break for long unbroken strings (SKUs, URLs, emails) */
.ds-break-word {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Truncate utility */
.ds-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ==========================================================================
   REDUCED MOTION — WCAG 2.1 AA accessibility requirement
   Zero instances existed before this. Affects all animations/transitions.
   ========================================================================== */

@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;
    }

    /* Allow essential loading spinners to still indicate "working" */
    .fa-spin,
    .fa-spinner {
        animation-duration: 2s !important;
        animation-iteration-count: infinite !important;
    }
}


/* ==========================================================================
   RTL ICON FLIPPING — Directional icons that must mirror in RTL
   51 fa-arrow-* and 5 fa-chevron-* instances not flipped before this.
   ========================================================================== */

html[dir="rtl"] .fa-arrow-left,
html[dir="rtl"] .fa-arrow-right,
html[dir="rtl"] .fa-chevron-left,
html[dir="rtl"] .fa-chevron-right,
html[dir="rtl"] .fa-arrow-circle-left,
html[dir="rtl"] .fa-arrow-circle-right,
html[dir="rtl"] .fa-long-arrow-left,
html[dir="rtl"] .fa-long-arrow-right,
html[dir="rtl"] .fa-long-arrow-alt-left,
html[dir="rtl"] .fa-long-arrow-alt-right,
html[dir="rtl"] .fa-angle-left,
html[dir="rtl"] .fa-angle-right,
html[dir="rtl"] .fa-angle-double-left,
html[dir="rtl"] .fa-angle-double-right,
html[dir="rtl"] .fa-caret-left,
html[dir="rtl"] .fa-caret-right {
    transform: scaleX(-1);
}

/* Prevent double-flip when icon is inside an already-flipped parent */
html[dir="rtl"] [style*="scaleX(-1)"] .fa-arrow-left,
html[dir="rtl"] [style*="scaleX(-1)"] .fa-arrow-right {
    transform: none;
}


/* ==========================================================================
   DOUBLE-SUBMIT PREVENTION — Visual state for disabled buttons during submit
   app.js disables buttons but never re-enables on error. This provides
   visual feedback and a CSS class for JS to toggle.
   ========================================================================== */

/* Submitting state: show spinner, reduce opacity */
.btn.is-submitting,
.btn[disabled] {
    opacity: 0.65;
    pointer-events: none;
    position: relative;
}

/* Loading spinner overlay on submitting buttons */
.btn.is-submitting::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-inline-start: 8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ds-spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes ds-spin {
    to { transform: rotate(360deg); }
}

/* Reduced motion: static indicator instead of spinner */
@media (prefers-reduced-motion: reduce) {
    .btn.is-submitting::after {
        animation: none;
        border-right-color: currentColor;
        opacity: 0.5;
    }
}


/* ==========================================================================
   ERROR STATES — Visual feedback for failed operations
   ========================================================================== */

/* Form field with error */
.form-control.is-invalid,
.form-control.has-error,
.has-error .form-control {
    border-color: var(--ds-color-danger-700, #b42318) !important;
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12) !important;
}

/* Error message below field */
.ds-field-error {
    color: var(--ds-color-danger-700, #b42318);
    font-size: var(--ds-font-size-xs, 0.75rem);
    margin-top: var(--ds-spacing-1, 0.25rem);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Network error banner */
.ds-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--ds-color-danger-700, #b42318);
    color: white;
    text-align: center;
    padding: 8px 16px;
    font-size: var(--ds-font-size-sm, 0.875rem);
    font-weight: var(--ds-font-weight-medium, 500);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.ds-offline-banner.active {
    transform: translateY(0);
}

/* Dark mode error states */
html[data-ui-theme="dark"] .ds-field-error {
    color: #fca5a5;
}

html[data-ui-theme="dark"] .form-control.is-invalid,
html[data-ui-theme="dark"] .form-control.has-error,
html[data-ui-theme="dark"] .has-error .form-control {
    border-color: #fca5a5 !important;
    box-shadow: 0 0 0 3px rgba(252, 165, 165, 0.12) !important;
}

/* ============================================================
   Tailwind Polyfill — Missing utilities from the compiled
   public/css/tailwind/app.css (positioning, z-index, responsive
   grid variants, a few colors). Loaded after tailwind/app.css so
   these act as a safety net for blade files that use tw-* classes
   the compiler's purge dropped.
   ============================================================ */

/* Position utilities */
.tw-fixed   { position: fixed !important; }
.tw-absolute { position: absolute !important; }
.tw-relative { position: relative !important; }
.tw-sticky  { position: sticky !important; }
.tw-static  { position: static !important; }

/* Inset shorthand (full cover) */
.tw-inset-0 { top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; }
.tw-top-0    { top: 0 !important; }
.tw-right-0  { right: 0 !important; }
.tw-bottom-0 { bottom: 0 !important; }
.tw-left-0   { left: 0 !important; }

/* Z-index utilities */
.tw-z-0  { z-index: 0 !important; }
.tw-z-10 { z-index: 10 !important; }
.tw-z-20 { z-index: 20 !important; }
.tw-z-30 { z-index: 30 !important; }
.tw-z-40 { z-index: 40 !important; }
.tw-z-50 { z-index: 50 !important; }

/* Semi-transparent black backgrounds (modal overlays) */
.tw-bg-black\/50 { background-color: rgba(0, 0, 0, 0.5) !important; }
.tw-bg-black\/40 { background-color: rgba(0, 0, 0, 0.4) !important; }
.tw-bg-black\/60 { background-color: rgba(0, 0, 0, 0.6) !important; }

/* Responsive grid columns — md: (≥768px) and lg: (≥1024px) */
@media (min-width: 768px) {
    .md\:tw-grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
    .md\:tw-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .md\:tw-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .md\:tw-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    .md\:tw-text-base  { font-size: 1rem !important; line-height: 1.5rem !important; }
    .md\:tw-text-lg    { font-size: 1.125rem !important; line-height: 1.75rem !important; }
    .md\:tw-text-xl    { font-size: 1.25rem !important; line-height: 1.75rem !important; }
    .md\:tw-text-2xl   { font-size: 1.5rem !important; line-height: 2rem !important; }
    .md\:tw-text-3xl   { font-size: 1.875rem !important; line-height: 2.25rem !important; }
}

@media (min-width: 1024px) {
    .lg\:tw-grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
    .lg\:tw-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .lg\:tw-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .lg\:tw-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}

@media (min-width: 1280px) {
    .xl\:tw-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .xl\:tw-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}

/* Col-span for empty states */
.tw-col-span-1 { grid-column: span 1 / span 1 !important; }
.tw-col-span-2 { grid-column: span 2 / span 2 !important; }
.tw-col-span-3 { grid-column: span 3 / span 3 !important; }
.tw-col-span-full { grid-column: 1 / -1 !important; }

/* ============================================================
   Sections Page — Redesigned components
   Used by: resources/views/restaurant/sections/index.blade.php
   ============================================================ */

/* Page header */
.sections-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}
.sections-header__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 26px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}
.sections-header__title i {
    color: #4f46e5;
    font-size: 22px;
}
.sections-header__subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Toolbar — branch select + search + primary CTA */
.sections-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.sections-toolbar__field {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.sections-toolbar__field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin: 0;
    white-space: nowrap;
}
.sections-toolbar__select {
    min-width: 220px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    font-size: 14px;
    color: #111827;
    transition: border-color .15s, box-shadow .15s;
}
.sections-toolbar__select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.sections-toolbar__spacer { flex: 1 1 auto; }
.sections-toolbar__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #4f46e5;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .15s;
    text-decoration: none;
}
.sections-toolbar__cta:hover {
    background: #4338ca;
    transform: translateY(-1px);
}
.sections-toolbar__cta:active { transform: translateY(0); }

/* Today's shift date pill */
.sections-toolbar__date {
    padding: 8px 14px;
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* Grid — auto-fill, responsive without media queries */
.sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

/* Card */
.section-card {
    --section-color: #4f46e5;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
    display: flex;
    flex-direction: column;
    position: relative;
}
.section-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    border-color: #d1d5db;
}
/* Top color accent strip */
.section-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--section-color);
}

.section-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px 12px;
    gap: 10px;
}
.section-card__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}
.section-card__icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--section-color) 12%, white);
    color: var(--section-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex: 0 0 auto;
}
.section-card__title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Kebab menu */
.section-card__kebab {
    position: relative;
    flex: 0 0 auto;
}
.section-card__kebab-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.section-card__kebab-btn:hover {
    background: #f3f4f6;
    color: #111827;
}
.section-card__kebab-menu {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    min-width: 160px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    padding: 6px;
    z-index: 20;
    display: none;
}
.section-card__kebab-menu.open { display: block; }
.section-card__kebab-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 14px;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
}
.section-card__kebab-menu a:hover { background: #f3f4f6; }
.section-card__kebab-menu a.danger { color: #dc2626; }
.section-card__kebab-menu a.danger:hover { background: #fef2f2; }
.section-card__kebab-menu i { width: 14px; }

/* Capacity */
.section-card__capacity {
    padding: 0 20px 14px;
}
.section-card__capacity-head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}
.section-card__capacity-head strong { color: #111827; font-weight: 700; }
.section-card__capacity-bar {
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}
.section-card__capacity-fill {
    height: 100%;
    background: var(--section-color);
    border-radius: 3px;
    transition: width .3s ease;
}

/* Body sections */
.section-card__body {
    padding: 0 20px;
    flex: 1 1 auto;
}
.section-card__group {
    margin-bottom: 14px;
}
.section-card__group-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-card__group-label .count {
    background: #f3f4f6;
    color: #374151;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 10px;
}
.section-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}
.section-card__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: color-mix(in srgb, var(--section-color) 10%, white);
    color: var(--section-color);
    border: 1px solid color-mix(in srgb, var(--section-color) 25%, white);
}
.section-card__chip.server {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}
.section-card__chip--readonly {
    padding: 4px 12px;
    background: #f9fafb;
    color: #4b5563;
    border-color: #e5e7eb;
}
.section-card__chip button {
    background: transparent;
    border: 0;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    margin: 0;
}
.section-card__chip button:hover { opacity: 1; color: #dc2626; }
.section-card__empty-chips {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* Footer combo actions */
.section-card__footer {
    padding: 14px 20px;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.section-card__combo {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.section-card__combo select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    background: #ffffff;
    font-size: 12px;
    color: #374151;
}
.section-card__combo select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.section-card__combo-btn {
    flex: 0 0 auto;
    padding: 0 14px;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background .15s;
}
.section-card__combo-btn:hover { background: #4338ca; }
.section-card__combo-btn.alt { background: #10b981; }
.section-card__combo-btn.alt:hover { background: #059669; }

/* Empty state */
.sections-empty {
    grid-column: 1 / -1;
    padding: 60px 24px;
    background: #ffffff;
    border: 2px dashed #e5e7eb;
    border-radius: 16px;
    text-align: center;
}
.sections-empty__icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}
.sections-empty__title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 8px;
}
.sections-empty__text {
    font-size: 14px;
    color: #6b7280;
    max-width: 420px;
    margin: 0 auto 24px;
    line-height: 1.6;
}
.sections-empty__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .15s;
    text-decoration: none;
}
.sections-empty__cta:hover {
    background: #4338ca;
    transform: translateY(-1px);
    color: #ffffff;
}

/* Modal — centered card, proper overlay */
.sections-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    z-index: 1050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.sections-modal.open { display: flex; }
.sections-modal__card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 24px 28px;
    animation: sectionsModalIn .2s ease-out;
}
@keyframes sectionsModalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.sections-modal__title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sections-modal__title i { color: #4f46e5; }
.sections-modal__field {
    margin-bottom: 16px;
}
.sections-modal__field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.sections-modal__field input[type="text"],
.sections-modal__field input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    transition: border-color .15s, box-shadow .15s;
}
.sections-modal__field input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Icon picker */
.icon-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.icon-picker input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.icon-picker label {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 16px;
    border: 2px solid transparent;
    transition: all .15s;
    margin: 0;
}
.icon-picker label:hover {
    background: #eef2ff;
    color: #4f46e5;
    transform: translateY(-1px);
}
.icon-picker input[type="radio"]:checked + label {
    background: #4f46e5;
    color: #ffffff;
    border-color: #312e81;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}
html[data-ui-theme="dark"] .icon-picker label {
    background: #334155;
    color: #94a3b8;
}
html[data-ui-theme="dark"] .icon-picker label:hover {
    background: #1e293b;
    color: #818cf8;
}

/* Drag handle on section card (appears on hover) */
.section-card__drag-handle {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s;
    z-index: 5;
}
.section-card:hover .section-card__drag-handle {
    opacity: 1;
}
.section-card__drag-handle:hover {
    background: #f3f4f6;
    color: #4f46e5;
}
.section-card__drag-handle:active { cursor: grabbing; }
html[data-ui-theme="dark"] .section-card__drag-handle { color: #475569; }
html[data-ui-theme="dark"] .section-card__drag-handle:hover {
    background: #334155;
    color: #818cf8;
}

/* Sortable "ghost" state while dragging */
.section-card.sortable-ghost {
    opacity: 0.4;
    background: #eef2ff;
}
.section-card.sortable-drag {
    opacity: 0.9;
    transform: rotate(2deg);
    cursor: grabbing;
}

/* Color swatch picker */
.color-swatches {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.color-swatches input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.color-swatches label {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    border: 3px solid transparent;
    transition: transform .15s, border-color .15s;
    display: block;
    margin: 0;
}
.color-swatches label:hover { transform: scale(1.1); }
.color-swatches input[type="radio"]:checked + label,
.color-swatches label.checked {
    border-color: #111827;
    transform: scale(1.1);
}
.color-swatches input[type="radio"]:checked + label::after,
.color-swatches label.checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.sections-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
}
.sections-modal__btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .15s;
}
.sections-modal__btn--ghost {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
}
.sections-modal__btn--ghost:hover { background: #f9fafb; color: #111827; }
.sections-modal__btn--primary {
    background: #4f46e5;
    color: #ffffff;
}
.sections-modal__btn--primary:hover { background: #4338ca; }

/* Dark mode adjustments */
html[data-ui-theme="dark"] .sections-header__title { color: #f1f5f9; }
html[data-ui-theme="dark"] .sections-header__title i { color: #818cf8; }
html[data-ui-theme="dark"] .sections-header__subtitle { color: #94a3b8; }
html[data-ui-theme="dark"] .sections-toolbar {
    background: #1e293b;
    border-color: #334155;
}
html[data-ui-theme="dark"] .sections-toolbar__field label { color: #cbd5e1; }
html[data-ui-theme="dark"] .sections-toolbar__select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
html[data-ui-theme="dark"] .section-card {
    background: #1e293b;
    border-color: #334155;
}
html[data-ui-theme="dark"] .section-card__title { color: #f1f5f9; }
html[data-ui-theme="dark"] .section-card__capacity-head { color: #94a3b8; }
html[data-ui-theme="dark"] .section-card__capacity-head strong { color: #e2e8f0; }
html[data-ui-theme="dark"] .section-card__capacity-bar { background: #334155; }
html[data-ui-theme="dark"] .section-card__group-label { color: #64748b; }
html[data-ui-theme="dark"] .section-card__group-label .count {
    background: #334155;
    color: #cbd5e1;
}
html[data-ui-theme="dark"] .section-card__footer {
    background: #0f172a;
    border-top-color: #334155;
}
html[data-ui-theme="dark"] .section-card__combo select {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
html[data-ui-theme="dark"] .section-card__kebab-btn { color: #94a3b8; }
html[data-ui-theme="dark"] .section-card__kebab-btn:hover {
    background: #334155;
    color: #f1f5f9;
}
html[data-ui-theme="dark"] .section-card__kebab-menu {
    background: #1e293b;
    border-color: #334155;
}
html[data-ui-theme="dark"] .section-card__kebab-menu a { color: #cbd5e1; }
html[data-ui-theme="dark"] .section-card__kebab-menu a:hover { background: #334155; }
html[data-ui-theme="dark"] .sections-empty {
    background: #1e293b;
    border-color: #334155;
}
html[data-ui-theme="dark"] .sections-empty__title { color: #f1f5f9; }
html[data-ui-theme="dark"] .sections-empty__text { color: #94a3b8; }
html[data-ui-theme="dark"] .sections-modal__card {
    background: #1e293b;
}
html[data-ui-theme="dark"] .sections-modal__title { color: #f1f5f9; }
html[data-ui-theme="dark"] .sections-modal__field label { color: #cbd5e1; }
html[data-ui-theme="dark"] .sections-modal__field input[type="text"],
html[data-ui-theme="dark"] .sections-modal__field input[type="number"] {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

/* RTL: flip breadcrumb chevron to point right-to-left */
html[dir="rtl"] .breadcrumb-chevron {
    transform: scaleX(-1);
}

/* =====================================================================
   Spec 189 — button alignment in Bootstrap modal footers
   ---------------------------------------------------------------------
   Bootstrap 3's `.modal-footer .btn + .btn { margin-left: 5px }` rule only
   matches `.btn`, so the Tailwind/daisy `.tw-dw-btn` buttons we now use in
   133 views render flush against each other. Worse, an `<a class="tw-dw-btn">`
   next to a `<button class="tw-dw-btn">` sits on a different baseline
   (anchors are plain inline boxes, buttons are inline-block with the UA's
   own line-height), so the pair looks vertically staggered — the misaligned
   "Home / Open Register" pair in the Perfumery POS register modal is one
   instance of this, not a one-off.

   Normalise both element types to the same inline-flex box and restore the
   inter-button gap, LTR and RTL. Scoped to modal/actions containers so this
   cannot alter buttons in page bodies.
   ===================================================================== */
.modal-footer a.tw-dw-btn,
.modal-footer button.tw-dw-btn,
.ds-modal-actions a.tw-dw-btn,
.ds-modal-actions button.tw-dw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    text-decoration: none;
}

.modal-footer a.tw-dw-btn:hover,
.modal-footer a.tw-dw-btn:focus,
.ds-modal-actions a.tw-dw-btn:hover,
.ds-modal-actions a.tw-dw-btn:focus {
    text-decoration: none;
}

/* Gap between adjacent action buttons, whichever button system they use. */
.modal-footer .tw-dw-btn + .tw-dw-btn,
.modal-footer .tw-dw-btn + .btn,
.modal-footer .btn + .tw-dw-btn,
.ds-modal-actions .tw-dw-btn + .tw-dw-btn {
    margin-left: 8px;
}

html[dir="rtl"] .modal-footer .tw-dw-btn + .tw-dw-btn,
html[dir="rtl"] .modal-footer .tw-dw-btn + .btn,
html[dir="rtl"] .modal-footer .btn + .tw-dw-btn,
html[dir="rtl"] .ds-modal-actions .tw-dw-btn + .tw-dw-btn {
    margin-left: 0;
    margin-right: 8px;
}
