/* ============================================================
   Koomi POS - Global View Consistency (scoped)
   Styles the shared Koomi shell classes (page header, unified
   cards, standard forms, show grids, stat tiles) used by the
   x-page-header and x-koomi.* components.

   IMPORTANT: this file is intentionally scoped to `.page-header`
   and `koomi-*` classes. It deliberately avoids blanket element
   overrides (`.card`, `form input`, `.table`) so it can be loaded
   app-wide without regressing bespoke/polished pages (e.g. the
   POS screen, gradient hero cards, print invoices).
============================================================ */
:root {
    --koomi-card-radius: 14px;
    --koomi-border: #e5e7eb;
    --koomi-muted: #64748b;
    --koomi-title: #0f172a;
    --koomi-bg-soft: #f8fafc;
    --koomi-primary: #3498db;
    --koomi-danger: #ef4444;
}

/* One page header style everywhere (x-page-header renders .page-header) */
.koomi-auto-page-header,
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.koomi-auto-page-header .page-title h4,
.page-header .page-title h4 {
    color: var(--koomi-title);
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
}

.koomi-auto-page-header .page-title h6,
.page-header .page-title h6 {
    color: var(--koomi-muted);
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.koomi-breadcrumb,
.page-header .breadcrumb {
    background: transparent;
    padding: 0;
    margin: 7px 0 0;
    font-size: 13px;
}

.koomi-breadcrumb a,
.page-header .breadcrumb a { color: var(--koomi-primary); font-weight: 600; }
.koomi-breadcrumb .active,
.page-header .breadcrumb .active { color: var(--koomi-muted); font-weight: 600; }

/* Unified cards — scoped to koomi shells only */
.koomi-unified-card,
.koomi-form-card,
.koomi-show-card {
    border: 1px solid var(--koomi-border);
    border-radius: var(--koomi-card-radius);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
    overflow: visible;
}

.koomi-unified-card .card-header,
.koomi-card-header {
    background: #fff;
    border-bottom: 1px solid var(--koomi-border);
    padding: 16px 18px;
    border-radius: var(--koomi-card-radius) var(--koomi-card-radius) 0 0;
}

.koomi-unified-card .card-body { padding: 18px; }
.koomi-unified-card .card-footer,
.koomi-form-actions {
    background: #fff;
    border-top: 1px solid var(--koomi-border);
    padding: 14px 18px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Unified form layout — scoped to koomi forms */
.koomi-standard-form .form-label,
.koomi-standard-form label,
.koomi-module-form .form-label,
.koomi-module-form label {
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.koomi-required-star { color: var(--koomi-danger); margin-left: 3px; }

.koomi-standard-form .form-control,
.koomi-standard-form .form-select,
.koomi-standard-form select,
.koomi-standard-form input:not([type="checkbox"]):not([type="radio"]),
.koomi-standard-form textarea,
.koomi-module-form .form-control,
.koomi-module-form .form-select,
.koomi-module-form select,
.koomi-module-form input:not([type="checkbox"]):not([type="radio"]),
.koomi-module-form textarea {
    min-height: 40px;
    border-radius: 10px;
    border-color: #d0d7e2;
    color: #1f2937;
}

.koomi-standard-form textarea,
.koomi-module-form textarea { min-height: 92px; }

.koomi-standard-form .form-control:focus,
.koomi-standard-form .form-select:focus,
.koomi-standard-form select:focus,
.koomi-standard-form input:focus,
.koomi-standard-form textarea:focus,
.koomi-module-form .form-control:focus,
.koomi-module-form .form-select:focus,
.koomi-module-form select:focus,
.koomi-module-form input:focus,
.koomi-module-form textarea:focus {
    border-color: #8fb4ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.koomi-invalid-field {
    border-color: var(--koomi-danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10) !important;
}

.koomi-form-error-summary {
    display: none;
    border: 1px solid #fecaca;
    background: #fff1f2;
    color: #991b1b;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-weight: 600;
}
.koomi-form-error-summary.show { display: block; }

/* Unified action buttons — scoped inside koomi shells */
.koomi-standard-form .btn-submit,
.koomi-module-form .btn-submit,
.koomi-primary-btn {
    border-radius: 10px;
    font-weight: 700;
}

.koomi-submit-disabled,
.koomi-real-submit:disabled,
.koomi-final-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Unified show/detail grids */
.koomi-show-grid,
.legacy-form-grid {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 10px 14px;
    align-items: center;
}

.koomi-show-grid label,
.legacy-form-grid label {
    color: #64748b;
    font-size: 13px;
    font-weight: 800;
    margin: 0;
}

.koomi-readonly,
.legacy-readonly {
    background: var(--koomi-bg-soft);
    border: 1px solid var(--koomi-border);
    color: #111827;
    border-radius: 10px;
    min-height: 40px;
    padding: 9px 12px;
    font-weight: 600;
    word-break: break-word;
}

.koomi-stat,
.legacy-stat {
    background: #fff;
    border: 1px solid var(--koomi-border);
    border-radius: 14px;
    padding: 14px;
    min-height: 88px;
}
.koomi-stat span,
.legacy-stat span { display: block; color: var(--koomi-muted); font-weight: 700; font-size: 12px; }
.koomi-stat strong,
.legacy-stat strong { display: block; color: var(--koomi-title); font-weight: 800; font-size: 20px; margin-top: 8px; }

/* Clickable DataTable rows (opt-in via .koomi-clickable-row / data-href) */
.dataTable tbody tr[data-href],
.dataTable tbody tr.koomi-clickable-row { cursor: pointer; }
.dataTable tbody tr[data-href]:hover,
.dataTable tbody tr.koomi-clickable-row:hover { background: #f8fbff; }

/* Select2 dropdown overlay/component polish (safe, cosmetic) */
.select2-container { width: 100% !important; max-width: 100% !important; }
.select2-container--open { z-index: 999999 !important; }
.select2-dropdown {
    z-index: 999999 !important;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(15,23,42,.16);
}
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid #d0d7e2;
    border-radius: 10px;
    min-height: 40px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 38px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 38px; }
.select2-results__options { max-height: 240px; overflow-y: auto; }

@media (max-width: 767px) {
    .koomi-show-grid,
    .legacy-form-grid { grid-template-columns: 1fr; }
    .koomi-auto-page-header,
    .page-header { display: block; }
    .page-header .page-btn { margin-top: 12px; }
}

/* ── Unified value colour ─────────────────────────────────────────────────
   Every entered / selected value renders in the same dark tone. Select2 was
   painting its value #637381 (dark grey) while plain inputs were near-black,
   which made the same row look inconsistent. Placeholders stay muted. */
.form-control,
.form-select,
select.form-control,
textarea.form-control,
.select2-container .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    color: #0f172a !important;
}

.form-control::placeholder,
.select2-container--default .select2-selection__placeholder {
    color: #94a3b8 !important;
}

/* ──────────────────────────────────────────────────────────────────────
   No horizontal page scroll, anywhere.
   Wide content (tables, modals) scrolls inside its own container instead
   of pushing the page sideways.
   ────────────────────────────────────────────────────────────────────── */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.page-wrapper,
.page-wrapper > .content {
    max-width: 100%;
    overflow-x: hidden;
}

/* Modals must never scroll sideways — their tables wrap or shrink instead. */
.modal .table-responsive {
    overflow-x: auto;
}

.modal-body {
    overflow-x: hidden;
}

/* Long unbroken values (SKUs, barcodes, IMEIs) wrap instead of widening the table. */
.table td,
.table th {
    overflow-wrap: anywhere;
}

/* ──────────────────────────────────────────────────────────────────────
   Lebanon phone inputs — a 🇱🇧 +961 addon in a Bootstrap input-group, so the
   prefix and the digits sit side by side and never overlap.
   ────────────────────────────────────────────────────────────────────── */
.koomi-phone-wrap {
    flex-wrap: nowrap;
}

.koomi-phone-prefix {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: #f1f5f9;
    border-color: #d8dce5;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.koomi-phone-prefix .koomi-flag {
    font-size: 1.05rem;
    line-height: 1;
}

.koomi-phone-prefix .koomi-cc {
    letter-spacing: .01em;
}

/* The input fills the rest of the group and keeps normal padding. */
.koomi-phone-input {
    min-width: 0;
    flex: 1 1 auto;
}
