/* ============================================
   CM App — Razor-Specific Overrides
   ============================================ */

/* ── Bridge: map old cm-* CSS variables to template variables ── */
:root {
    --cm-emerald: var(--color-primary);
    --cm-emerald-light: var(--color-primary-hover);
    --cm-navy: var(--color-primary-ink);
    --cm-navy-light: #243044;
    --cm-copper: var(--color-accent);
    --cm-copper-muted: #a0643a;
    --cm-sand: #d4b896;
    --cm-beige: var(--color-surface-alt);
    --cm-offwhite: var(--color-bg);
    --cm-bg: var(--color-bg);
    --cm-surface: var(--color-surface);
    --cm-text: var(--color-text);
    --cm-text-muted: var(--color-text-muted);
    --cm-border: var(--color-border);
    --cm-card-shadow: var(--shadow-sm);
    --cm-card-hover-shadow: var(--shadow-lg);
    --cm-font: var(--font-sans);
    --cm-font-heading: var(--font-sans);
    --cm-transition: var(--transition);
    --cm-navbar-gradient: linear-gradient(135deg, var(--color-primary-ink) 0%, var(--color-primary-hover) 50%, var(--color-primary) 100%);
    --cm-hero-gradient: linear-gradient(160deg, var(--color-primary-ink) 0%, var(--color-primary-hover) 40%, var(--color-primary) 100%);
    --cm-cta-gradient: linear-gradient(135deg, var(--color-primary-ink) 0%, var(--color-primary-hover) 60%, var(--color-primary) 100%);
}

/* ── Lightweight grid (replaces Bootstrap grid) ── */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: calc(var(--s-3) * -0.5);
}

.row>* {
    padding: calc(var(--s-3) * 0.5);
    box-sizing: border-box;
    flex: 0 0 100%;
    max-width: 100%;
}

.g-3 {
    margin: calc(var(--s-3) * -0.5);
}

.g-3>* {
    padding: calc(var(--s-3) * 0.5);
}

.g-4 {
    margin: calc(var(--s-4) * -0.5);
}

.g-4>* {
    padding: calc(var(--s-4) * 0.5);
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

@media (min-width: 576px) {
    .col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (min-width: 768px) {
    .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .col-md-4 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-8 {
        flex: 0 0 66.667%;
        max-width: 66.667%;
    }

    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (min-width: 992px) {
    .col-lg-2 {
        flex: 0 0 16.667%;
        max-width: 16.667%;
    }

    .col-lg-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .col-lg-4 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .col-lg-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-lg-8 {
        flex: 0 0 66.667%;
        max-width: 66.667%;
    }
}

/* ── Additional utilities ── */
.flex-column {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-center {
    justify-content: center;
}

.align-start {
    align-items: flex-start;
}

.text-end {
    text-align: end;
}

.fw-bold {
    font-weight: 700;
}

.fw-semibold {
    font-weight: 600;
}

.fs-sm {
    font-size: var(--fs-sm);
}

.fs-xs {
    font-size: var(--fs-xs);
}

.p-4 {
    padding: var(--s-4);
}

.py-5 {
    padding-top: var(--s-5);
    padding-bottom: var(--s-5);
}

.min-w-0 {
    min-width: 0;
}

/* Loading overlay */
.cm-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 28, 46, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.cm-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: cm-spin 0.6s linear infinite;
}

@keyframes cm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Alert messages (TempData) */
.cm-alert {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    font-weight: 500;
    margin-bottom: var(--s-4);
    position: relative;
    animation: cm-alert-in 0.25s ease;
}

@keyframes cm-alert-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cm-alert-success {
    background: var(--color-success-soft);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

[data-theme="dark"] .cm-alert-success {
    color: #6ee7b7;
    border-color: #07302a;
}

.cm-alert-danger {
    background: var(--color-danger-soft);
    color: #991b1b;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .cm-alert-danger {
    color: #fca5a5;
    border-color: #3a1b1b;
}

.cm-alert-info {
    background: var(--color-info-soft);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

[data-theme="dark"] .cm-alert-info {
    color: #93c5fd;
    border-color: #132240;
}

.cm-alert-warning {
    background: var(--color-warning-soft);
    color: #92400e;
    border: 1px solid #fde68a;
}

[data-theme="dark"] .cm-alert-warning {
    color: #fcd34d;
    border-color: #3a2c0b;
}

.cm-alert .cm-alert-close {
    margin-inline-start: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--fs-lg);
    color: inherit;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
}

.cm-alert .cm-alert-close:hover {
    opacity: 1;
}

.cm-alert svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Validation errors */
.field-validation-error,
.cm-validation-error {
    color: var(--color-danger);
    font-size: var(--fs-xs);
    margin-top: 4px;
    display: block;
}

.input-validation-error {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 15%, transparent) !important;
}

.validation-summary-errors {
    background: var(--color-danger-soft);
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: var(--radius);
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-4);
    font-size: var(--fs-sm);
}

[data-theme="dark"] .validation-summary-errors {
    color: #fca5a5;
    border-color: #3a1b1b;
}

.validation-summary-errors ul {
    margin: 0;
    padding-inline-start: var(--s-4);
}

.validation-summary-valid {
    display: none;
}

/* Select2 overrides for new template */
.select2-container--default .select2-selection--single {
    height: 42px !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius) !important;
    background: var(--color-surface) !important;
    padding: 0 var(--s-3);
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--color-text) !important;
    font-size: var(--fs-sm);
    padding: 0 !important;
    line-height: 42px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px !important;
    inset-inline-end: 8px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--color-text-soft) !important;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--color-primary) !important;
    color: #fff !important;
}

.select2-container--default .select2-selection--single:focus-within,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent) !important;
}

.select2-dropdown {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius) !important;
    background: var(--color-surface) !important;
    box-shadow: var(--shadow-lg) !important;
}

.select2-results__option {
    color: var(--color-text) !important;
    font-size: var(--fs-sm) !important;
    padding: 8px var(--s-3) !important;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--color-surface-alt) !important;
    color: var(--color-text) !important;
    font-size: var(--fs-sm) !important;
    height: 36px;
    padding: 0 var(--s-3);
}

/* Select2 multiple */
.select2-container--default .select2-selection--multiple {
    min-height: 42px !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius) !important;
    background: var(--color-surface) !important;
    padding: 4px var(--s-2);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--color-primary-soft) !important;
    color: var(--color-primary-ink) !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    font-size: var(--fs-xs) !important;
    padding: 4px 8px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--color-primary-ink) !important;
}

/* Toast notification */
.cm-toast {
    position: fixed;
    top: 80px;
    z-index: 9999;
    min-width: 320px;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--s-4);
    animation: cm-toast-in 0.3s ease;
}

html[dir="ltr"] .cm-toast {
    right: 20px;
}

html[dir="rtl"] .cm-toast {
    left: 20px;
}

@keyframes cm-toast-in {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Password strength indicator */
.pw-strength {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.pw-strength span {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border);
    transition: background 0.2s;
}

.pw-strength span.weak {
    background: var(--color-danger);
}

.pw-strength span.fair {
    background: var(--color-warning);
}

.pw-strength span.good {
    background: var(--color-info);
}

.pw-strength span.strong {
    background: var(--color-success);
}

/* Role selection cards (register page) */
.role-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-3);
}

.role-card {
    position: relative;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--s-5) var(--s-4);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--color-surface);
}

.role-card:hover {
    border-color: var(--color-border-strong);
}

.role-card.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.role-card input[type="radio"] {
    display: none;
}

.role-card .role-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    margin: 0 auto var(--s-3);
    font-size: 20px;
}

.role-card .role-icon.customer {
    background: var(--color-info-soft);
    color: var(--color-info);
}

.role-card .role-icon.craftsman {
    background: var(--color-accent-soft);
    color: #b45309;
}

.role-card .role-label {
    font-weight: 600;
    font-size: var(--fs-sm);
    display: block;
}

.role-card .role-desc {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    display: block;
    margin-top: 2px;
}

/* Pager */
.cm-pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    margin-top: var(--s-5);
}

.cm-pager-info {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

.cm-pager-list {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cm-pager-list a,
.cm-pager-list span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    font-size: var(--fs-xs);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all var(--transition);
}

.cm-pager-list a:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}

.cm-pager-list .active span {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.cm-pager-list .disabled span,
.cm-pager-list .disabled a {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* File attachment previews */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--s-3);
    margin-top: var(--s-3);
}

.attachment-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.attachment-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-item .remove-btn {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-danger);
    color: #fff;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 12px;
}

/* Bootstrap Icons integration */
[class^="bi-"]::before,
[class*=" bi-"]::before {
    vertical-align: -0.125em;
}

/* Utility: optional label */
.optional {
    font-weight: 400;
    font-size: var(--fs-xs);
    color: var(--color-text-soft);
}

/* Star rating */
.star-rating {
    display: flex;
    gap: 4px;
    font-size: 24px;
}

.star-rating .star {
    cursor: pointer;
    color: var(--color-border-strong);
    transition: color 0.15s;
}

.star-rating .star.active,
.star-rating .star:hover {
    color: var(--color-accent);
}

/* Detail rows (key-value pairs) */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-3);
}

@media (max-width: 600px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-value {
    font-size: var(--fs-sm);
    font-weight: 500;
}

/* Responsive form adjustments */
@media (max-width: 720px) {
    .role-grid {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Landing page footer */
.landing-footer {
    border-top: 1px solid var(--color-border);
    padding: var(--s-5) var(--s-7);
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

/* Page-level empty state */
.page-empty {
    text-align: center;
    padding: var(--s-10) var(--s-5);
    color: var(--color-text-muted);
}

.page-empty svg {
    width: 48px;
    height: 48px;
    color: var(--color-text-soft);
    margin-bottom: var(--s-3);
}

.page-empty h3 {
    font-size: var(--fs-md);
    color: var(--color-text);
    margin-bottom: var(--s-2);
}

.page-empty p {
    font-size: var(--fs-sm);
    max-width: 400px;
    margin: 0 auto;
}

/* ── Bootstrap utility aliases ── */
.align-items-center {
    align-items: center;
}

.align-items-start {
    align-items: flex-start;
}

.justify-content-center {
    justify-content: center;
}

.justify-content-between {
    justify-content: space-between;
}

.d-none {
    display: none !important;
}

.d-block {
    display: block;
}

.d-inline {
    display: inline;
}

.d-inline-flex {
    display: inline-flex;
}

.d-grid {
    display: grid;
}

.flex-fill {
    flex: 1 1 auto;
}

.text-decoration-none {
    text-decoration: none;
}

.text-body-secondary {
    color: var(--color-text-muted);
}

.text-primary {
    color: var(--color-primary);
}

.text-danger {
    color: var(--color-danger);
}

.text-dark {
    color: var(--color-text);
}

.text-start {
    text-align: start;
}

.small {
    font-size: var(--fs-sm);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-3 {
    margin-bottom: var(--s-3);
}

.mb-4 {
    margin-bottom: var(--s-4);
}

.ms-1 {
    margin-inline-start: 0.25rem;
}

.me-1 {
    margin-inline-end: 0.25rem;
}

.px-4 {
    padding-inline: var(--s-4);
}

.p-3 {
    padding: var(--s-3);
}

.fs-4 {
    font-size: var(--fs-xl);
}

.h-100 {
    height: 100%;
}

.w-100 {
    width: 100%;
}

.rounded-circle {
    border-radius: 50%;
}

.gap-2 {
    gap: var(--s-2);
}

/* ── Bootstrap form aliases ── */
.form-control,
.form-select {
    width: 100%;
    height: 42px;
    padding: 0 var(--s-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--fs-sm);
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

textarea.form-control {
    height: auto;
    padding: var(--s-3);
    resize: vertical;
}

.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
}

.form-check-input:not([role="switch"]) {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.form-check-label {
    font-size: var(--fs-sm);
    cursor: pointer;
}

/* ── Bootstrap alert aliases ── */
.alert {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    font-weight: 500;
    margin-bottom: var(--s-4);
}

.alert-danger {
    background: var(--color-danger-soft);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--color-warning-soft);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-success {
    background: var(--color-success-soft);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ── Bootstrap badge aliases ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.3;
}

.bg-success {
    background: var(--color-success) !important;
    color: #fff;
}

.bg-danger {
    background: var(--color-danger) !important;
    color: #fff;
}

.bg-warning {
    background: var(--color-warning) !important;
}

.text-dark {
    color: var(--color-text) !important;
}

.bg-secondary {
    background: var(--color-text-muted) !important;
    color: #fff;
}

.bg-primary {
    background: var(--color-primary) !important;
    color: #fff;
}

.bg-opacity-10 {
    opacity: 1;
    background: color-mix(in srgb, var(--color-primary) 10%, transparent) !important;
}

/* ── Bootstrap card shadow alias ── */
.shadow-sm {
    box-shadow: var(--shadow-sm);
}

/* ── Bootstrap button aliases ── */
.btn-outline-primary {
    background: transparent;
    border: 1.5px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-outline-primary:hover {
    background: var(--color-primary);
    color: #fff;
}

.btn-outline-secondary {
    background: transparent;
    border: 1.5px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline-secondary:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-secondary {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--fs-lg);
    color: var(--color-text-muted);
    padding: 4px;
    line-height: 1;
}

/* Do NOT override btn-close::after — Bootstrap uses a background SVG for the × icon */

/* ── Bootstrap modal - Let Bootstrap handle modals, only add theme colors ── */
.modal-content {
    background-color: var(--color-surface);
    border-color: var(--color-border);
}

.modal-header {
    border-bottom-color: var(--color-border);
}

.modal-footer {
    border-top-color: var(--color-border);
}

.modal-title {
    color: var(--color-text);
}

/* ── card-premium alias (used in ReportNoShow/RequestManualReview) ── */
.card-premium {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--s-5);
    box-shadow: var(--shadow-sm);
}

/* ── back-btn for dashboard pages ── */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    margin-bottom: var(--s-3);
}

.back-btn:hover {
    color: var(--color-primary);
}

/* ── input-field alias ── */
.input-field {
    width: 100%;
    padding: var(--s-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--fs-sm);
    font-family: inherit;
}

.input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

/* ── btn-gold / btn-danger-cm aliases ── */
.btn-gold {
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: var(--s-3) var(--s-5);
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
}

.btn-gold:hover {
    background: #d97706;
}

.btn-danger-cm {
    background: var(--color-danger);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: var(--s-3) var(--s-5);
    font-weight: 600;
    font-size: var(--fs-sm);
    cursor: pointer;
}

.btn-danger-cm:hover {
    background: #dc2626;
}

/* ── Additional Bootstrap utility aliases ── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.font-monospace {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.img-fluid {
    max-width: 100%;
    height: auto;
}

.border {
    border: 1px solid var(--color-border);
}

.rounded {
    border-radius: var(--radius);
}

.rounded-bottom {
    border-radius: 0 0 var(--radius) var(--radius);
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-secondary {
    color: var(--color-text-muted);
}

.text-success {
    color: var(--color-success);
}

.flex-grow-1 {
    flex-grow: 1;
}

.m-0 {
    margin: 0;
}

.mt-1 {
    margin-top: 0.25rem;
}

.me-2 {
    margin-inline-end: var(--s-2);
}

.mb-2 {
    margin-bottom: var(--s-2);
}

.p-0 {
    padding: 0;
}

.p-1 {
    padding: 0.25rem;
}

.py-2 {
    padding-top: var(--s-2);
    padding-bottom: var(--s-2);
}

.fs-3 {
    font-size: var(--fs-2xl);
}

.g-2 {
    margin: calc(var(--s-2) * -0.5);
}

.g-2>* {
    padding: calc(var(--s-2) * 0.5);
}

.bg-body-secondary {
    background: var(--color-surface-alt);
}

.bg-dark {
    background: var(--color-text) !important;
    color: #fff;
}

.btn-dark {
    background: var(--color-text);
    color: #fff;
    border: none;
}

.btn-dark:hover {
    opacity: 0.85;
}

.btn-orange {
    background: var(--color-accent);
    color: #fff;
    border: none;
}

.btn-orange:hover {
    background: #d97706;
}

@media (min-width: 576px) {
    .col-sm-4 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .col-sm-8 {
        flex: 0 0 66.667%;
        max-width: 66.667%;
    }
}

@media (min-width: 768px) {
    .col-md-1 {
        flex: 0 0 8.333%;
        max-width: 8.333%;
    }

    .col-md-2 {
        flex: 0 0 16.667%;
        max-width: 16.667%;
    }

    .col-md-5 {
        flex: 0 0 41.667%;
        max-width: 41.667%;
    }
}

@media (min-width: 992px) {
    .col-lg-10 {
        flex: 0 0 83.333%;
        max-width: 83.333%;
    }
}

/* form-switch (toggle) — color overrides only, Bootstrap handles the rendering */
.form-switch .form-check-input {
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
    border-color: var(--color-primary);
}

/* pagination (Bootstrap compat) */
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 4px;
}

.page-item {
    display: inline-flex;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    font-size: var(--fs-xs);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all var(--transition);
}

.page-link:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.page-item.active .page-link {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
}

.pagination-sm .page-link {
    min-width: 28px;
    height: 28px;
    font-size: 0.7rem;
}

/* dropdown (used in some admin views) */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    z-index: 100;
    min-width: 180px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 8px 14px;
    font-size: var(--fs-sm);
    color: var(--color-text);
    text-decoration: none;
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--color-surface-alt);
}

.dropdown-divider {
    border-top: 1px solid var(--color-border);
    margin: 4px 0;
}

/* empty-state alias */
.empty-state {
    text-align: center;
    padding: var(--s-8) var(--s-4);
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}

/* admin stat card — inherits from shared.css .cm-admin-card
   Only add overrides here that are specific to cm-app context.
   Do NOT redefine base styles (background, border, border-radius, padding)
   to avoid cascade conflicts with shared.css. */

/* Remove hover lift on admin form cards — only stat/dashboard cards should lift */
.cm-admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-3);
}

/* ── Auth-page floating topbar (language + theme on login/register) ── */
.auth-topbar {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
}

.auth-topbar .icon-btn {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--color-text);
    border-radius: var(--radius);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-1);
    font-size: var(--fs-xs);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.auth-topbar .icon-btn:hover {
    background: rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .auth-topbar .icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
}

[data-theme="dark"] .auth-topbar .icon-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* wider button when it has text (language label) */
.auth-topbar .icon-btn:has(i) {
    width: auto;
    padding: 0 var(--s-3);
}

/* ── Comprehensive RTL support ── */

/* Font family: Arabic uses Tajawal, English uses Inter */
html[dir="rtl"] {
    font-family: 'Tajawal', 'Inter', var(--font-sans);
}

html[dir="ltr"] {
    font-family: 'Inter', var(--font-sans);
}

/* Flip directional icons */
html[dir="rtl"] .bi-arrow-left::before {
    content: "\f12f";
    /* bi-arrow-right */
}

html[dir="rtl"] .bi-arrow-right::before {
    content: "\f127";
    /* bi-arrow-left */
}

html[dir="rtl"] .bi-chevron-right::before {
    content: "\f284";
    /* bi-chevron-left */
}

html[dir="rtl"] .bi-chevron-left::before {
    content: "\f285";
    /* bi-chevron-right */
}

html[dir="rtl"] .bi-box-arrow-right::before {
    content: "\f1c4";
    /* bi-box-arrow-left */
}

/* Auth hero: mirror layout in RTL */
html[dir="rtl"] .auth-shell {
    direction: rtl;
}

html[dir="rtl"] .auth-hero {
    text-align: right;
}

html[dir="rtl"] .auth-form-wrap {
    text-align: right;
}

/* Sidebar text alignment */
html[dir="rtl"] .sidebar {
    text-align: right;
}

/* Table text alignment */
html[dir="rtl"] table th,
html[dir="rtl"] table td {
    text-align: right;
}

/* Form labels */
html[dir="rtl"] .label,
html[dir="rtl"] .field label {
    text-align: right;
}

/* Validation messages alignment */
html[dir="rtl"] .field-validation-error,
html[dir="rtl"] .cm-validation-error,
html[dir="rtl"] .validation-summary-errors {
    text-align: right;
}

/* Modal direction */
html[dir="rtl"] .modal-content {
    direction: rtl;
    text-align: right;
}

/* Dropdown alignment */
html[dir="rtl"] .dropdown-menu {
    text-align: right;
}

/* Breadcrumb direction */
html[dir="rtl"] .breadcrumb {
    direction: rtl;
}

/* Page header - flex items keep natural flow but text aligns right */
html[dir="rtl"] .cm-page-header,
html[dir="rtl"] .page-header {
    text-align: right;
}

/* Button icon gap: logical properties handle this but ensure flex-direction */
html[dir="rtl"] .cm-btn i,
html[dir="rtl"] .btn i {
    order: 0;
}

/* Select2 RTL */
html[dir="rtl"] .select2-container {
    direction: rtl;
}

html[dir="rtl"] .select2-dropdown {
    direction: rtl;
    text-align: right;
}

/* Card text */
html[dir="rtl"] .card,
html[dir="rtl"] .cm-admin-card,
html[dir="rtl"] .cm-stat-card,
html[dir="rtl"] .stat-card,
html[dir="rtl"] .cm-card {
    text-align: right;
}

/* Navigation link active indicator — uses border-inline-start (already logical) */
/* Ensure spacing uses logical properties */
html[dir="rtl"] .nav-item {
    padding-right: var(--s-4);
    padding-left: var(--s-2);
}

html[dir="ltr"] .nav-item {
    padding-left: var(--s-4);
    padding-right: var(--s-2);
}

/* User menu alignment */
html[dir="rtl"] .user-menu {
    direction: rtl;
    text-align: right;
}

/* Topbar search icon position */
html[dir="rtl"] .topbar-search svg {
    right: auto;
    left: initial;
}

/* Empty state */
html[dir="rtl"] .cm-empty-state,
html[dir="rtl"] .empty-state {
    text-align: center;
    /* centered regardless */
}

/* Pagination */
html[dir="rtl"] .pagination {
    direction: rtl;
}

/* Filter panels */
html[dir="rtl"] .cm-filter-bar {
    direction: rtl;
    text-align: right;
}

/* ============================================
   Bootstrap Modal Theme Integration
   ============================================ */

/* Only override colors and minor styling - let Bootstrap handle positioning */
.modal-backdrop {
    background-color: rgba(15, 28, 46, 0.5);
}

[data-theme="dark"] .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Theme colors for modal */
.modal-content {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background-color: var(--color-surface);
    border-bottom-color: var(--color-border);
}

.modal-body {
    background-color: var(--color-surface);
    color: var(--color-text);
}

.modal-footer {
    background-color: var(--color-surface);
    border-top-color: var(--color-border);
}

/* RTL support for close button */
html[dir="rtl"] .modal-header .btn-close {
    margin-left: 0;
    margin-right: auto;
}