/* ═══════════════════════════════════════════════════════════════════════════
   Telecom Voucher — MODERN SHELL
   Comprehensive premium enterprise UI modernization.
   Loaded after design-system.css and enterprise-enhancements.css.
   Overrides and extends the existing design system.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. ROOT ENHANCEMENTS ────────────────────────────────────────────── */

:root {
    --tv-radius-xl: 16px;
    --tv-radius-2xl: 20px;
    --tv-shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.18);
    --tv-shadow-glow: 0 0 20px rgba(var(--tv-primary-rgb), 0.15);
    --tv-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --tv-ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --tv-transition-fast: 150ms;
    --tv-transition-base: 250ms;
    --tv-transition-slow: 400ms;
}

html[data-theme="dark"] {
    --tv-shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --tv-shadow-glow: 0 0 24px rgba(var(--tv-primary-rgb), 0.22);
}

/* ── 2. TYPOGRAPHY ───────────────────────────────────────────────────── */

.tv-theme {
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.tv-page-title {
    font-family: var(--tv-font-display);
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.2;
    color: var(--tv-text);
}

.tv-page-sub {
    font-size: 0.9rem;
    color: var(--tv-text-muted);
    font-weight: 400;
    line-height: 1.5;
    max-width: 48rem;
}

.tv-theme h1,
.tv-theme .h1,
.tv-theme h2,
.tv-theme .h2,
.tv-theme h3,
.tv-theme .h3 {
    font-family: var(--tv-font-display);
    letter-spacing: -0.02em;
}

.tv-theme h2,
.tv-theme .h2 {
    font-size: 1.35rem;
    font-weight: 700;
}

.tv-theme h3,
.tv-theme .h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

/* ── 3. SHELL & LAYOUT ───────────────────────────────────────────────── */

.tv-shell-main {
    background: transparent;
}

/* tv-master-ui gives .tv-shell-main z-index:1; that traps in-main fixed modals below body .modal-backdrop until reparent. */
.tv-app > .tv-shell-main {
    z-index: auto;
}

/* Main content fills .tv-shell-main — outer rhythm; inner page body lives in .tv-page-content-shell (white panel + 10px padding). */
.tv-page-wrap {
    padding: var(--tv-space-3, 0.75rem) 0.5rem 2.25rem;
}

@media (min-width: 768px) {
    .tv-page-wrap {
        padding: var(--tv-space-3, 0.75rem) 0.75rem 2.75rem;
    }
}

@media (min-width: 1400px) {
    .tv-page-wrap {
        padding: var(--tv-space-4, 1rem) 1rem 3rem;
    }
}

/* Inset panel: all page markup sits inside this wrapper (see _Layout.cshtml). */
.tv-page-content-shell {
    box-sizing: border-box;
    width: 100%;
    padding: 10px;
    background-color: #ffffff;
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-md, 0.5rem);
}

html[data-theme="dark"] .tv-page-content-shell {
    background-color: var(--tv-surface-elevated, var(--tv-surface));
    border-color: var(--tv-border);
}

.tv-shell-main:not(.tv-main--guest) > main.tv-page-wrap > .tv-page-content-shell {
    flex: 1 1 auto;
    min-height: 0;
}

/* ── 4. SIDEBAR PREMIUM ──────────────────────────────────────────────── */

.tv-sidebar {
    border-inline-end: 1px solid var(--tv-border);
    background: var(--tv-sidebar-bg);
    /* position:fixed is set in design-system.css — do NOT override here */
    transition:
        width var(--tv-transition-base) var(--tv-ease-smooth),
        min-width var(--tv-transition-base) var(--tv-ease-smooth);
}

html[data-theme="dark"] .tv-sidebar {
    background: var(--tv-sidebar-bg);
}

.tv-sidebar__brand {
    padding: 1.5rem 1.25rem 1.25rem;
}

.tv-sidebar__logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.9375rem;
    box-shadow:
        0 2px 8px rgba(var(--tv-primary-rgb), 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.tv-sidebar__nav {
    padding: 0.5rem 0.75rem 1rem;
    gap: 1px;
}

.tv-sidebar-link {
    padding: 0.65rem 0.875rem;
    border-radius: var(--tv-radius-md);
    margin-bottom: 1px;
    position: relative;
    font-size: 0.8125rem;
    transition: all var(--tv-transition-fast) var(--tv-ease-smooth);
    color: var(--tv-sidebar-link-fg, var(--tv-text-secondary));
}

.tv-sidebar-link::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--tv-primary);
    border-radius: 0 4px 4px 0;
    transition: transform var(--tv-transition-fast) var(--tv-ease-out);
}

html[dir="rtl"] .tv-sidebar-link::before {
    left: auto;
    right: 0;
    border-radius: 4px 0 0 4px;
}

.tv-sidebar-link:hover {
    background: var(--tv-sidebar-link-hover-bg, var(--tv-bg-muted));
    color: var(--tv-sidebar-link-hover-fg, var(--tv-text));
    transform: translateX(1px);
}

[dir="rtl"] .tv-sidebar-link:hover {
    transform: translateX(-1px);
}

.tv-sidebar-link.active {
    background: var(--tv-sidebar-active-bg, var(--tv-nav-active-grad));
    color: var(--tv-sidebar-active-fg, var(--tv-primary));
    border-color: var(--tv-sidebar-active-border, var(--tv-nav-active-border));
    font-weight: 600;
}

.tv-sidebar-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.tv-sidebar-link.active .tv-sidebar-icon {
    color: var(--tv-sidebar-active-icon, var(--tv-primary));
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(var(--tv-primary-rgb), 0.35));
}

.tv-sidebar-submenu {
    margin: 0.25rem 0 0.5rem;
    padding: 0;
}

.tv-sidebar-submenu .tv-sidebar-link {
    padding-block: 0.5rem;
    padding-inline-end: 0.875rem;
    padding-inline-start: 2.25rem;
    font-size: 0.78rem;
    opacity: 0.92;
}

.tv-sidebar-submenu .tv-sidebar-link:hover {
    opacity: 1;
}

.tv-sidebar__section-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tv-sidebar-section-fg, var(--tv-text-muted));
    padding: 1rem 0.875rem 0.35rem;
    opacity: 0.92;
}

.tv-sidebar__divider {
    margin: 0.5rem 0.875rem;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--tv-divider),
        transparent
    );
    opacity: 0.6;
}

/* Sidebar user panel */
.tv-sidebar__footer {
    padding: 0.875rem;
    border-top: 1px solid var(--tv-border);
    background: var(--tv-sidebar-bg);
    margin-top: auto;
}

.tv-sidebar-user {
    padding: 0.5rem;
    border-radius: var(--tv-radius-md);
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.tv-sidebar-user__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tv-primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.8125rem;
    font-weight: 700;
    flex-shrink: 0;
}

.tv-sidebar-user__name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--tv-text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.tv-sidebar-user__hint {
    font-size: 0.6875rem;
    color: var(--tv-text-muted);
}

.tv-btn-sidebar-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--tv-radius-md);
    border: 1px solid var(--tv-border);
    background: transparent;
    color: var(--tv-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    transition: all var(--tv-transition-fast) ease;
}

.tv-btn-sidebar-logout:hover {
    background: var(--tv-danger-soft);
    color: var(--tv-danger);
    border-color: rgba(220, 38, 38, 0.2);
}

/* ── 5. TOPBAR PREMIUM ───────────────────────────────────────────────── */

.tv-topbar {
    background: var(--tv-bg-app);
    border-bottom: 1px solid var(--tv-border);
    height: var(--tv-topbar-height);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: var(--tv-z-topbar, 1030);
}

html[data-theme="dark"] .tv-topbar {
    background: var(--tv-bg-app);
    border-bottom-color: var(--tv-border);
}

/* Hamburger menu button — hidden (sidebar is always visible fixed) */
.tv-theme .tv-topbar__menu {
    display: none;
}

.tv-theme .tv-topbar__menu:hover {
    background: var(--tv-bg-muted);
    color: var(--tv-text);
}

.tv-search {
    background: var(--tv-bg-muted);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-pill);
    padding: 0.4rem 0.875rem;
    transition: all var(--tv-transition-fast) ease;
    max-width: 280px;
    width: 100%;
}

.tv-search:focus-within {
    border-color: rgba(var(--tv-primary-rgb), 0.4);
    box-shadow: 0 0 0 3px var(--tv-primary-soft);
    background: var(--tv-surface);
}

.tv-search input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 0.8125rem;
    color: var(--tv-text);
    width: 100%;
}

.tv-search input::placeholder {
    color: var(--tv-text-muted);
}

.tv-btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--tv-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    color: var(--tv-text-secondary);
    transition: all var(--tv-transition-fast) ease;
    cursor: pointer;
}

.tv-btn-icon:hover {
    background: var(--tv-bg-muted);
    color: var(--tv-text);
    border-color: var(--tv-border-strong);
    transform: translateY(-1px);
}

.tv-btn-icon:active {
    transform: translateY(0);
}

.tv-lang-switch:not(.tv-lang-switch--segmented) a {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tv-text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: var(--tv-radius-sm);
    transition: all var(--tv-transition-fast) ease;
}

.tv-lang-switch:not(.tv-lang-switch--segmented) a:hover {
    background: var(--tv-bg-muted);
    color: var(--tv-text);
}

.tv-lang-switch:not(.tv-lang-switch--segmented) a.fw-semibold {
    color: var(--tv-primary);
    background: var(--tv-primary-soft);
}

/* ── 6. PREMIUM CARDS ────────────────────────────────────────────────── */

.tv-card {
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    box-shadow: var(--tv-card-shadow);
    overflow: hidden;
    transition: box-shadow var(--tv-transition-base) var(--tv-ease-smooth);
}

.tv-card:hover {
    box-shadow: var(--tv-shadow-sm);
}

/* Lists with scrollable grids: card lift/border pulse fights the inner scroll area — keep row/cell hovers only */
.tv-theme .tv-card:has(> .tv-card-body .tv-table-scroll):hover {
    transform: none;
    box-shadow: var(--tv-card-shadow);
    border-color: var(--tv-border);
}

.tv-card-body {
    padding: 1.5rem;
}

.tv-card-header {
    padding: 1.25rem 1.5rem;
    background: transparent;
    border-bottom: 1px solid var(--tv-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.tv-card-header h2,
.tv-card-header h3,
.tv-card-header .h5 {
    font-family: var(--tv-font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--tv-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.tv-card-footer {
    padding: 1rem 1.5rem;
    background: var(--tv-bg-muted);
    border-top: 1px solid var(--tv-border);
}

/* Card variants */
.tv-card--elevated {
    box-shadow: var(--tv-shadow-md);
}

.tv-card--elevated:hover {
    box-shadow: var(--tv-shadow-lg);
    transform: translateY(-2px);
}

.tv-card--glass {
    background: var(--tv-glass-bg);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}

.tv-card--feature {
    border: 1px solid var(--tv-border);
    background: var(--tv-bg-muted);
}

/* ── 7. PREMIUM FORMS ────────────────────────────────────────────────── */

.tv-form-page {
    max-width: 720px;
}

.tv-form-page .tv-card-body {
    padding: 2rem;
}

@media (max-width: 575.98px) {
    .tv-form-page .tv-card-body {
        padding: 1.25rem;
    }
}

.tv-form-section-title {
    font-family: var(--tv-font-display);
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    color: var(--tv-text-secondary);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--tv-border);
    position: relative;
}

.tv-form-section-title::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    bottom: -2px;
    width: 48px;
    height: 2px;
    background: var(--tv-primary);
    border-radius: 2px;
}

.tv-theme .form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--tv-text-secondary);
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}

.tv-theme .form-control,
.tv-theme .form-select {
    min-height: 2.75rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border-radius: var(--tv-radius-md);
    border: 1.5px solid var(--tv-border);
    /* background-color only: `background` shorthand resets select chevron repeat/size */
    background-color: var(--tv-surface);
    color: var(--tv-text);
    box-shadow: var(--tv-shadow-inset-input);
    transition:
        border-color var(--tv-transition-fast) ease,
        box-shadow var(--tv-transition-fast) ease,
        background-color var(--tv-transition-fast) ease;
}

.tv-theme .form-control:hover,
.tv-theme .form-select:hover {
    border-color: var(--tv-border-strong);
}

.tv-theme .form-control:focus,
.tv-theme .form-select:focus {
    border-color: rgba(var(--tv-primary-rgb), 0.5);
    box-shadow:
        var(--tv-shadow-inset-input),
        0 0 0 4px var(--tv-primary-soft);
    background-color: var(--tv-surface);
    outline: none;
}

.tv-theme .form-control::placeholder {
    color: var(--tv-text-hint);
    font-weight: 400;
}

.tv-theme .form-control:disabled,
.tv-theme .form-select:disabled {
    background-color: var(--tv-bg-muted);
    opacity: 0.7;
    cursor: not-allowed;
}

.tv-theme textarea.form-control {
    min-height: 6rem;
    resize: vertical;
}

/* Validation states */
.tv-theme .form-control.is-invalid,
.tv-theme .form-select.is-invalid,
.tv-theme .form-control.input-validation-error,
.tv-theme .form-select.input-validation-error {
    border-color: var(--tv-danger);
    background-image: none;
    padding-inline-end: 0.875rem;
}

.tv-theme .form-control.is-invalid:focus,
.tv-theme .form-select.is-invalid:focus,
.tv-theme .form-control.input-validation-error:focus,
.tv-theme .form-select.input-validation-error:focus {
    border-color: var(--tv-danger);
    box-shadow:
        var(--tv-shadow-inset-input),
        0 0 0 4px var(--tv-danger-soft);
}

.tv-theme .invalid-feedback,
.tv-theme .field-validation-error {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--tv-danger);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.tv-theme .invalid-feedback::before,
.tv-theme .field-validation-error::before {
    content: "!";
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--tv-danger);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Checkbox / radio */
.tv-theme .form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    border: 1.5px solid var(--tv-border-strong);
    border-radius: 4px;
    transition: all var(--tv-transition-fast) ease;
}

.tv-theme .form-check-input:checked {
    background-color: var(--tv-primary);
    border-color: var(--tv-primary);
    box-shadow: 0 0 0 3px var(--tv-primary-soft);
}

.tv-theme .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--tv-primary-soft);
    border-color: var(--tv-primary);
}

/* Form action bar */
.tv-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--tv-border);
}

/* ── 8. PREMIUM BUTTONS ──────────────────────────────────────────────── */

.tv-theme .btn {
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
    padding: 0.6rem 1.25rem;
    border-radius: var(--tv-radius-md);
    transition: all var(--tv-transition-fast) var(--tv-ease-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    line-height: 1.4;
    white-space: nowrap;
}

.tv-theme .btn:active {
    transform: scale(0.97);
}

.tv-theme .btn:disabled,
.tv-theme .btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

.tv-theme .btn-primary {
    background: linear-gradient(
        145deg,
        var(--tv-primary) 0%,
        var(--tv-primary-deep) 100%
    );
    border: 1px solid var(--tv-primary-deep);
    color: #fff;
    box-shadow:
        0 2px 8px rgba(var(--tv-primary-rgb), 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.tv-theme .btn-primary:hover {
    background: linear-gradient(
        145deg,
        var(--tv-primary-hover) 0%,
        var(--tv-primary) 100%
    );
    border-color: var(--tv-primary);
    box-shadow:
        0 4px 16px rgba(var(--tv-primary-rgb), 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    transform: translateY(-1px);
}

.tv-theme .btn-primary:active {
    box-shadow: 0 1px 4px rgba(var(--tv-primary-rgb), 0.2);
}

.tv-theme .btn-outline-primary {
    border: 1.5px solid rgba(var(--tv-primary-rgb), 0.4);
    color: var(--tv-primary);
    background: transparent;
}

.tv-theme .btn-outline-primary:hover {
    background: var(--tv-primary-soft);
    border-color: var(--tv-primary);
    color: var(--tv-primary-on-soft);
    transform: translateY(-1px);
}

.tv-theme .btn-outline-secondary {
    border: 1.5px solid var(--tv-border);
    color: var(--tv-text-secondary);
    background: transparent;
}

.tv-theme .btn-outline-secondary:hover {
    background: var(--tv-bg-muted);
    border-color: var(--tv-border-strong);
    color: var(--tv-text);
    transform: translateY(-1px);
}

.tv-theme .btn-danger {
    background: linear-gradient(145deg, #ef4444 0%, #dc2626 100%);
    border: 1px solid #dc2626;
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

.tv-theme .btn-danger:hover {
    background: linear-gradient(145deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
    transform: translateY(-1px);
}

.tv-theme .btn-success {
    background: linear-gradient(145deg, #10b981 0%, #059669 100%);
    border: 1px solid #059669;
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.tv-theme .btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.75rem;
    min-height: 2rem;
}

.tv-theme .btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    min-height: 3rem;
}

/* Icon-only button variant */
.tv-btn-icon-only {
    padding: 0;
    width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
}

/* ── 9. PREMIUM TABLES ───────────────────────────────────────────────── */

.tv-table-scroll {
    border-radius: var(--tv-radius-xl);
    border: 1px solid var(--tv-border);
    /* Allow inner scroll; tv-datatables.css refines overflow per table type */
    overflow: auto;
    background: var(--tv-surface);
    box-shadow: var(--tv-card-shadow);
}

.tv-table-scroll table {
    margin-bottom: 0 !important;
}

.tv-table-scroll thead th {
    background: var(--app-header-excel, #0a5c48);
    color: var(--tv-on-primary, #ffffff);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.875rem 1rem;
    border: none;
    border-bottom: 2px solid var(--app-table-outline, #8eb3a8);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 3;
}

html[data-theme="dark"] .tv-table-scroll thead th {
    background: var(--tv-surface-elevated);
    color: var(--tv-text);
    border-bottom-color: var(--tv-border-strong);
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"][data-ui-brand="enterprise"] .tv-table-scroll thead th {
    background: var(--app-header-excel);
    color: var(--tv-text);
    border-bottom-color: var(--app-table-outline, var(--tv-border-strong));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.tv-table-scroll tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
    color: var(--tv-text);
    border: none;
    border-bottom: 1px solid var(--tv-border);
    vertical-align: middle;
}

.tv-table-scroll tbody tr:last-child td {
    border-bottom: none;
}

.tv-table-scroll tbody tr {
    transition: background-color var(--tv-transition-fast) ease;
}

.tv-table-scroll tbody tr:hover {
    background: var(--tv-bg-muted);
}

/* Table footer / pager area */
.tv-table-card-footer {
    background: var(--tv-bg-muted);
    border-top: 1px solid var(--tv-border);
    padding: 0.875rem 1.25rem;
}

/* ── 10. PREMIUM ALERTS ──────────────────────────────────────────────── */

.tv-theme .alert {
    border-radius: var(--tv-radius-lg);
    border: 1px solid transparent;
    padding: 1rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.tv-theme .alert::before {
    content: "";
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
}

.tv-theme .alert-success {
    background: var(--tv-success-soft);
    color: var(--tv-success-text);
    border-color: rgba(16, 185, 129, 0.2);
}

.tv-theme .alert-success::before {
    background: var(--tv-success);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E")
        center / 12px no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E")
        center / 12px no-repeat;
}

.tv-theme .alert-danger {
    background: var(--tv-danger-soft);
    color: var(--tv-danger-text);
    border-color: rgba(220, 38, 38, 0.2);
}

.tv-theme .alert-danger::before {
    background: var(--tv-danger);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E")
        center / 12px no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E")
        center / 12px no-repeat;
}

.tv-theme .alert-info {
    background: rgba(var(--tv-primary-rgb), 0.06);
    color: var(--tv-primary-deep);
    border-color: rgba(var(--tv-primary-rgb), 0.2);
}

.tv-theme .alert-info::before {
    background: var(--tv-primary);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'%3E%3C/line%3E%3C/svg%3E")
        center / 12px no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'%3E%3C/line%3E%3C/svg%3E")
        center / 12px no-repeat;
}

.tv-theme .alert-warning {
    background: var(--tv-warning-soft);
    color: #92400e;
    border-color: rgba(249, 115, 22, 0.2);
}

.tv-theme .alert-light.border {
    background: var(--tv-surface);
    border-color: var(--tv-border) !important;
    color: var(--tv-text-secondary);
}

html[data-theme="dark"] .tv-theme .alert-warning {
    color: var(--tv-accent-orange-hover);
}

/* ── 11. PREMIUM MODALS ──────────────────────────────────────────────── */

.tv-theme .modal-content {
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    box-shadow: var(--tv-shadow-2xl);
    background: var(--tv-surface);
    overflow: hidden;
}

.tv-theme .modal-header {
    background: var(--tv-bg-muted);
    border-bottom: 1px solid var(--tv-border);
    padding: 1.25rem 1.5rem;
}

.tv-theme .modal-title {
    font-family: var(--tv-font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tv-text);
    letter-spacing: -0.02em;
}

.tv-theme .modal-body {
    padding: 1.5rem;
    color: var(--tv-text);
}

.tv-theme .modal-footer {
    border-top: 1px solid var(--tv-border);
    background: var(--tv-bg-muted);
    padding: 1rem 1.5rem;
    gap: 0.75rem;
}

.tv-theme .modal-backdrop.show {
    opacity: 0.4;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ── 12. PAGINATION ────────────────────────────────────────────────────── */

.tv-pager-nav {
    gap: 0.35rem;
}

.tv-pager-link {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--tv-radius-md);
    border: 1.5px solid var(--tv-border);
    background: var(--tv-surface);
    color: var(--tv-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all var(--tv-transition-fast) ease;
}

.tv-pager-link:hover:not(.tv-pager-link--disabled):not(.tv-pager-link--active) {
    background: var(--tv-bg-muted);
    border-color: var(--tv-border-strong);
    color: var(--tv-text);
    transform: translateY(-1px);
    box-shadow: var(--tv-shadow-xs);
}

.tv-pager-link--active {
    background: var(--tv-primary);
    border-color: var(--tv-primary);
    color: #fff !important;
}

.tv-pager-link--disabled {
    opacity: 0.35;
}

/* ── 13. FILTER BAR ──────────────────────────────────────────────────── */

.tv-filter-bar {
    background: transparent;
    gap: 0.75rem;
}

.tv-filter-bar .form-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tv-text-muted);
    margin-bottom: 0.3rem;
}

.tv-filter-bar .form-control,
.tv-filter-bar .form-select {
    font-size: 0.8125rem;
    min-height: 2.5rem;
}

.tv-filter-bar .btn {
    min-height: 2.5rem;
}

/* ── 14. BREADCRUMB PREMIUM ──────────────────────────────────────────── */

.tv-breadcrumb {
    margin-bottom: 0.75rem;
    padding: 0;
    background: transparent;
    display: flex;
    width: auto;
}

.tv-breadcrumb__list {
    gap: 0.25rem;
    font-size: 0.75rem;
}

.tv-breadcrumb__item:not(:last-child)::after {
    width: 4px;
    height: 4px;
    opacity: 0.4;
}

.tv-breadcrumb__link {
    padding: 0.15rem 0.35rem;
    border-radius: var(--tv-radius-sm);
    transition: all var(--tv-transition-fast) ease;
}

.tv-breadcrumb__link:hover:not(.tv-breadcrumb__link--current) {
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
}

.tv-breadcrumb__link--current {
    font-weight: 600;
    color: var(--tv-text);
}

/* ── 15. FOOTER ──────────────────────────────────────────────────────── */

.tv-footer {
    background: transparent;
    border-top: 1px solid var(--tv-border);
    padding: 1rem 0;
    margin-top: auto;
}

.tv-footer__inner {
    font-size: 0.75rem;
    color: var(--tv-text-muted);
    text-align: center;
    font-weight: 500;
    opacity: 0.8;
}

/* ── 16. SECTION HEADER ──────────────────────────────────────────────── */

.tv-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--tv-border);
}

.tv-section-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* ── 17. ANIMATIONS ──────────────────────────────────────────────────── */

@keyframes tv-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tv-scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes tv-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.tv-animate-fade-in-up {
    animation: tv-fade-in-up 0.45s var(--tv-ease-out) both;
}

.tv-animate-scale-in {
    animation: tv-scale-in 0.35s var(--tv-ease-out) both;
}

.tv-delay-1 {
    animation-delay: 0.05s;
}
.tv-delay-2 {
    animation-delay: 0.1s;
}
.tv-delay-3 {
    animation-delay: 0.15s;
}
.tv-delay-4 {
    animation-delay: 0.2s;
}
.tv-delay-5 {
    animation-delay: 0.25s;
}
.tv-delay-6 {
    animation-delay: 0.3s;
}

/* ── 18. LOADING / SKELETON ──────────────────────────────────────────── */

.tv-skeleton-shimmer {
    background: linear-gradient(
        90deg,
        var(--tv-bg-muted) 25%,
        var(--tv-border-subtle) 50%,
        var(--tv-bg-muted) 75%
    );
    background-size: 200% 100%;
    animation: tv-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--tv-radius-sm);
}

/* ── 19. RESPONSIVE UTILITIES ───────────────────────────────────────── */

@media (max-width: 767.98px) {
    .tv-page-title {
        font-size: 1.35rem;
    }

    .tv-section-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .tv-section-header__actions {
        width: 100%;
    }

    .tv-section-header__actions .btn {
        flex: 1;
    }

    .tv-card-body {
        padding: 1.25rem;
    }

    .tv-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .tv-form-actions .btn {
        width: 100%;
    }

    .tv-table-scroll {
        border-radius: var(--tv-radius-lg);
    }

    .tv-pager-nav {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 575.98px) {
    .tv-page-wrap {
        padding: var(--tv-space-2, 0.5rem) 0.5rem 1.5rem;
    }

    .tv-card-body {
        padding: 1rem;
    }

    .tv-form-page .tv-card-body {
        padding: 1rem;
    }
}

/* ── 20. REDUCED MOTION ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .tv-animate-fade-in-up,
    .tv-animate-scale-in {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .tv-stat-card,
    .tv-stat-card-premium,
    .tv-report-card,
    .tv-offer-card,
    .tv-btn-accent,
    .tv-btn-dark {
        animation: none !important;
    }

    .tv-card:hover,
    .tv-sidebar-link:hover,
    .tv-btn-icon:hover,
    .tv-pager-link:hover,
    .tv-theme .btn:hover,
    .tv-theme .btn-primary:hover,
    .tv-theme .btn-outline-primary:hover,
    .tv-theme .btn-outline-secondary:hover,
    .tv-theme .btn-danger:hover {
        transform: none;
    }
}
/* ── 21. SIDEBAR COLLAPSED FLYOUT PREMIUM ─────────────────────────── */

:root {
    --tv-sidebar-collapsed-width: 84px !important;
}

.tv-sidebar--collapsed .tv-sidebar-link {
    width: 48px !important;
    height: 48px !important;
    margin: 10px auto !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 14px !important;
    border: 1px solid transparent !important;
    position: relative !important;
    transition: all var(--tv-transition-fast) var(--tv-ease-smooth) !important;
    background: transparent;
}

.tv-sidebar--collapsed .tv-sidebar-link::before {
    display: none !important; /* Hide side bar indicator in icon mode */
}

.tv-sidebar--collapsed .tv-sidebar-icon {
    width: 22px !important;
    height: 22px !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0.75;
}

.tv-sidebar--collapsed .tv-sidebar-link:hover {
    background: var(--tv-sidebar-link-hover-bg, var(--tv-bg-muted)) !important;
    color: var(--tv-sidebar-link-hover-fg, var(--tv-text)) !important;
    border-color: var(--tv-border) !important;
    transform: translateY(-1px);
}

.tv-sidebar--collapsed .tv-sidebar-link.active {
    background: var(--tv-sidebar-active-bg, var(--tv-nav-active-grad)) !important;
    color: var(--tv-sidebar-active-fg, var(--tv-primary)) !important;
    border-color: var(
            --tv-sidebar-active-border,
            rgba(var(--tv-primary-rgb), 0.2)
        ) !important;
    box-shadow: 0 4px 12px rgba(var(--tv-primary-rgb), 0.1) !important;
}

.tv-sidebar--collapsed .tv-sidebar-link.active .tv-sidebar-icon {
    opacity: 1;
    color: var(--tv-sidebar-active-icon, var(--tv-primary));
}

/* Sub-menu indicators (green dot) */
.tv-sidebar--collapsed .tv-sidebar-link--toggle::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid var(--tv-sidebar-inner);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    z-index: 5;
    transition: transform 0.2s ease;
}

.tv-sidebar--collapsed .tv-sidebar-link--toggle:hover::after {
    transform: scale(1.2);
}

/* Strictly hide original submenus and toggle icons in icon mode */
.tv-sidebar--collapsed .tv-sidebar-submenu,
.tv-sidebar--collapsed .collapse,
.tv-sidebar--collapsed .collapse.show,
.tv-sidebar--collapsed .collapsing,
.tv-sidebar--collapsed .tv-sidebar-link--toggle .ms-auto {
    display: none !important;
}

/* Extra box constraints: .collapsing drops .collapse, so the rule above still matches
   but inline height from Bootstrap can fight display; zero the box explicitly. */
.tv-sidebar--collapsed .collapsing {
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    border-width: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Premium Flyout Menu */
.tv-sidebar-flyout {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(var(--tv-primary-rgb), 0.15) !important;
    box-shadow:
        0 20px 40px -12px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(var(--tv-primary-rgb), 0.05),
        var(--tv-shadow-glow) !important;
    padding: 0.75rem !important;
    border-radius: var(--tv-radius-xl) !important;
    min-width: 240px !important;
    z-index: 2000 !important;
}

html[data-theme="dark"] .tv-sidebar-flyout {
    background: rgba(15, 23, 42, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow:
        0 20px 40px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        var(--tv-shadow-glow) !important;
}

.tv-sidebar-flyout__header {
    font-family: var(--tv-font-display);
    color: var(--tv-primary) !important;
    border-bottom: 1px solid var(--tv-divider) !important;
    padding: 0.25rem 0.75rem 0.75rem !important;
    margin-bottom: 0.5rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    pointer-events: none;
}

.tv-sidebar-flyout__list {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
}

.tv-sidebar-flyout__link {
    padding: 0.65rem 0.875rem !important;
    border-radius: var(--tv-radius-md) !important;
    transition: all var(--tv-transition-fast) var(--tv-ease-smooth) !important;
    border: 1px solid transparent !important;
    font-size: 0.8125rem !important;
    position: relative;
    z-index: 1;
}

.tv-sidebar-flyout__link:hover {
    background: var(--tv-primary-soft) !important;
    color: var(--tv-primary) !important;
    transform: translateX(4px);
    border-color: rgba(var(--tv-primary-rgb), 0.1) !important;
}

html[dir="rtl"] .tv-sidebar-flyout__link:hover {
    transform: translateX(-4px);
}

.tv-sidebar-flyout__link.active {
    background: var(--tv-nav-active-grad) !important;
    color: var(--tv-primary) !important;
    font-weight: 600 !important;
}

/* Main item active state when flyout is open */
.tv-sidebar--collapsed .tv-sidebar-link.tv-sidebar-link--active-flyout {
    background: var(--tv-sidebar-link-hover-bg, var(--tv-primary-soft)) !important;
    color: var(--tv-sidebar-link-hover-fg, var(--tv-primary)) !important;
    box-shadow: 0 0 0 1px rgba(var(--tv-primary-rgb), 0.2) inset !important;
    border-color: var(--tv-sidebar-active-border, rgba(var(--tv-primary-rgb), 0.3)) !important;
}

.tv-sidebar--collapsed
    .tv-sidebar-link.tv-sidebar-link--active-flyout
    .tv-sidebar-icon {
    color: var(--tv-sidebar-active-icon, var(--tv-primary));
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(var(--tv-primary-rgb), 0.35));
}
