/* ==========================================================================
   QuickOTA Admin Panel - Custom Styles
   Designed for light/dark theme support via MudBlazor CSS variables
   ========================================================================== */

/* --------------------------------------------------------------------------
   Base & Reset
   -------------------------------------------------------------------------- */

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Fix MudSelect popover appearing behind MudDialog overlay */
.mud-popover {
    z-index: 1400 !important;
}

/* --------------------------------------------------------------------------
   Login Page
   -------------------------------------------------------------------------- */

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--mud-palette-background);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    background: var(--mud-palette-surface);
    border-radius: 16px;
    border: 1px solid var(--mud-palette-divider);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
}

.login-form {
    margin-bottom: 8px;
}

.login-button {
    height: 48px !important;
    border-radius: 8px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em !important;
    text-transform: none !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
    transition: all 0.2s ease !important;
}

.login-button:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4) !important;
    transform: translateY(-1px);
}

@media (max-width: 480px) {
    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }
}

/* --------------------------------------------------------------------------
   Main Layout - AppBar
   -------------------------------------------------------------------------- */

.main-appbar {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
}

.main-appbar .mud-appbar {
    box-shadow: none !important;
}

.appbar-search {
    margin-left: 16px;
}

.appbar-search-field .mud-input-outlined {
    border-radius: 8px !important;
    background: var(--mud-palette-background) !important;
}

.appbar-search-field .mud-input-outlined .mud-input-outlined-border {
    border-color: var(--mud-palette-divider) !important;
}

.appbar-search-field .mud-input-outlined:hover .mud-input-outlined-border {
    border-color: var(--mud-palette-primary) !important;
}

.user-menu-btn {
    text-transform: none !important;
    padding: 4px 12px !important;
    border-radius: 8px !important;
}

.user-menu-btn:hover {
    background: var(--mud-palette-background) !important;
}

/* --------------------------------------------------------------------------
   Main Layout - Sidebar
   -------------------------------------------------------------------------- */

.sidebar-drawer .mud-drawer-content {
    background: #1E1B4B !important;
    display: flex;
    flex-direction: column;
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.sidebar-drawer .mud-drawer-header {
    display: none !important;
}

.sidebar-drawer .mud-appbar-fixed-adjust {
    display: none !important;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 12px 24px;
}

.sidebar-section-label {
    padding: 16px 24px 4px !important;
    color: #64748B !important;
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.1em !important;
    text-transform: uppercase !important;
}

.sidebar-nav .mud-nav-link {
    color: #94A3B8 !important;
    border-radius: 8px !important;
    margin: 2px 12px !important;
    padding: 10px 12px !important;
    transition: all 0.15s ease !important;
}

.sidebar-nav .mud-nav-link:hover {
    color: #E2E8F0 !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

.sidebar-nav .mud-nav-link.active {
    color: #fff !important;
    background: rgba(79, 70, 229, 0.4) !important;
}

.sidebar-nav .mud-nav-link .mud-nav-link-icon {
    color: inherit !important;
}

/* Collapsible module groups in the sidebar */
.sidebar-nav .mud-nav-group > .mud-nav-link {
    color: #CBD5E1 !important;
    border-radius: 8px !important;
    margin: 2px 12px !important;
    padding: 10px 12px !important;
    font-weight: 600 !important;
    transition: all 0.15s ease !important;
}

.sidebar-nav .mud-nav-group > .mud-nav-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

.sidebar-nav .mud-nav-group .mud-nav-link .mud-icon-root {
    color: inherit !important;
}

/* Nested links sit slightly indented and lighter than their group header */
.sidebar-nav .mud-nav-group .mud-collapse-container .mud-nav-link {
    padding-left: 24px !important;
    font-size: 0.875rem;
}

.sidebar-nav .mud-nav-group .mud-nav-link-expand-icon {
    color: #64748B !important;
}

/* --------------------------------------------------------------------------
   Quick Access Launcher
   -------------------------------------------------------------------------- */

.qa-module-card {
    border: 1px solid var(--mud-palette-divider);
    border-radius: 12px !important;
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.qa-module-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
    border-color: var(--mud-palette-primary);
}

.qa-module-card.expanded {
    border-color: var(--mud-palette-primary);
}

.qa-module-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    cursor: pointer;
    user-select: none;
}

.qa-module-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(79, 70, 229, 0.1);
}

.qa-module-icon .mud-icon-root {
    color: #4F46E5 !important;
    font-size: 1.4rem !important;
}

.qa-module-title {
    flex: 1;
    min-width: 0;
}

.qa-module-items {
    padding: 4px 12px 12px;
    border-top: 1px solid var(--mud-palette-divider);
}

.qa-module-item {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--mud-palette-text-primary);
    transition: background 0.12s ease;
}

.qa-module-item:hover {
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-primary);
}

.qa-module-item .mud-icon-root {
    color: var(--mud-palette-text-secondary);
}

.qa-module-item:hover .mud-icon-root {
    color: var(--mud-palette-primary);
}

.qa-leaf-card {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 12px !important;
    cursor: pointer;
    height: 100%;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.qa-leaf-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
    border-color: var(--mud-palette-primary);
    transform: translateY(-2px);
}

.qa-leaf-text {
    min-width: 0;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: auto;
}

.sidebar-user-details {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Main Content Area
   -------------------------------------------------------------------------- */

.main-content-area {
    background: var(--mud-palette-background) !important;
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Dashboard - Stat Cards
   -------------------------------------------------------------------------- */

.stat-card {
    padding: 24px !important;
    border-radius: 12px !important;
    border: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface) !important;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stat-card-footer {
    display: flex;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--mud-palette-divider);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .mud-icon-root {
    font-size: 1.4rem !important;
}

.stat-icon-primary {
    background: rgba(79, 70, 229, 0.1);
    color: #4F46E5;
}

.stat-icon-primary .mud-icon-root {
    color: #4F46E5 !important;
}

.stat-icon-success {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.stat-icon-success .mud-icon-root {
    color: #10B981 !important;
}

.stat-icon-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
}

.stat-icon-warning .mud-icon-root {
    color: #F59E0B !important;
}

.stat-icon-info {
    background: rgba(14, 165, 233, 0.1);
    color: #0EA5E9;
}

.stat-icon-info .mud-icon-root {
    color: #0EA5E9 !important;
}

/* --------------------------------------------------------------------------
   Dashboard - Chart Cards
   -------------------------------------------------------------------------- */

.chart-card {
    border-radius: 12px !important;
    border: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface) !important;
}

.chart-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.chart-filter-chips .mud-chip {
    font-size: 0.75rem !important;
}

/* --------------------------------------------------------------------------
   Dashboard - Activity Table
   -------------------------------------------------------------------------- */

.activity-table .mud-table-root {
    background: transparent !important;
}

.activity-table .mud-table-head .mud-table-cell {
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: var(--mud-palette-text-secondary) !important;
    border-bottom: 2px solid var(--mud-palette-divider) !important;
    background: transparent !important;
}

.activity-table .mud-table-body .mud-table-row:hover {
    background: var(--mud-palette-background) !important;
}

.activity-table .mud-table-cell {
    border-bottom: 1px solid var(--mud-palette-divider) !important;
}

/* --------------------------------------------------------------------------
   General Components
   -------------------------------------------------------------------------- */

/* Smoother transitions */
.mud-paper,
.mud-button,
.mud-icon-button {
    transition: all 0.15s ease !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--mud-palette-text-disabled);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mud-palette-text-secondary);
}

/* --------------------------------------------------------------------------
   Dark Mode Sidebar Adjustments
   -------------------------------------------------------------------------- */

/* In dark mode, make the sidebar slightly different from the page background */
.mud-theme-dark .sidebar-drawer .mud-drawer-content {
    background: #0F172A !important;
}

.mud-theme-dark .stat-icon-primary {
    background: rgba(99, 102, 241, 0.15);
}

.mud-theme-dark .stat-icon-success {
    background: rgba(52, 211, 153, 0.15);
}

.mud-theme-dark .stat-icon-warning {
    background: rgba(251, 191, 36, 0.15);
}

.mud-theme-dark .stat-icon-info {
    background: rgba(56, 189, 248, 0.15);
}

.mud-theme-dark .stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */

@media (max-width: 600px) {
    .appbar-search {
        display: none;
    }

    .stat-card {
        padding: 16px !important;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }
}

/* --------------------------------------------------------------------------
   Blazor Loading & Error UI
   -------------------------------------------------------------------------- */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Image drop zone (paste & drag-and-drop attachment areas) */
.image-drop-zone { position: relative; }
.image-drop-zone .image-drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    background: rgba(99, 102, 241, 0.08);
    border: 2px dashed #6366f1;
    border-radius: 12px;
    color: #4338ca;
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
}
.image-drop-zone.image-drop-active .image-drop-overlay { display: flex; }

/* Ticket list row styling — distinguish unread / replied vs idle tickets */
.ticket-row-unread { background: #fff7ed !important; border-left: 3px solid #ef4444; }
.ticket-row-unread .mud-table-cell { font-weight: 600; }
.ticket-row-awaiting-reply { background: #fefce8 !important; border-left: 3px solid #f59e0b; }
.ticket-row-replied { background: #f0fdf4 !important; border-left: 3px solid #22c55e; }
.ticket-row-closed { opacity: 0.7; }
.ticket-row-pending {
    background: #f5f3ff !important;
    border-left: 3px solid #8b5cf6;
}
.ticket-state-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }
.ticket-state-pill.unread { background: #fee2e2; color: #b91c1c; }
.ticket-state-pill.awaiting { background: #fef3c7; color: #b45309; }
.ticket-state-pill.replied { background: #dcfce7; color: #166534; }
.ticket-state-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Red unread-count badge inside the sidebar nav links */
.sidebar-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 8px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.18);
}

/* "NEW" pill rendered next to the ticket number for unreviewed Open tickets */
.ticket-new-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    margin-left: 8px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ─── Flight promotion chip ───
   The same chip the agent sees on the B2B results card, rendered in the admin
   list and in the edit dialog's live preview so the operator judges the real
   thing — label length and script included — before saving. Kept in sync with
   .fr-promo in TAM.AgencyPanel/Pages/FlightCloud/Results.razor.css.

   Violet, because every other colour on the flight card is already spoken for:
   green means refundable/included, amber means a warning (fee, scarce seats),
   red means missing, grey means not stated. Promotion is its own meaning and
   needs its own hue. */
.promo-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 100%;
    min-width: 0;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.6;
    padding: 1px 6px;
    border-radius: 5px;
    overflow: hidden;
    color: #5b21b6;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
}
.promo-chip__ic { font-size: 12px; line-height: 1; flex: 0 0 auto; }
/* Ellipsis on the text box, not the flex container — on the container it never
   fires and a long label is hard-clipped in silence, which is exactly what the
   preview exists to reveal. */
.promo-chip__txt {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Every kind shares the violet family so "this is promoted" reads at a glance;
   the kinds differ only in weight of tint, never in hue. */
.promo-chip--offer { color: #5b21b6; background: #f5f3ff; border-color: #ddd6fe; }
.promo-chip--best  { color: #4c1d95; background: #ede9fe; border-color: #c4b5fd; }
.promo-chip--reco  { color: #6d28d9; background: #faf5ff; border-color: #e9d5ff; }
.promo-chip--excl  { color: #4c1d95; background: #ede9fe; border-color: #c4b5fd; }

.promo-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--mud-palette-background-grey);
}

/* The agent's card is hard-coded white and the AgencyPanel results page has no
   dark theme, so the preview mock is white in BOTH themes — re-theming it would
   show the operator a chip no agent can ever see. Width is the agent's tag
   column at 1440px, so a label that will clip on the card clips here too. */
.promo-preview__card {
    display: flex;
    width: 130px;
    padding: 6px 8px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

/* .78 rather than .6: at 11-12px over the grey panel, .6 on TextPrimary
   measures 3.92:1 — under the 4.5:1 body floor. */
.promo-preview__caption {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.78;
}

.promo-preview__none { font-size: 12px; opacity: 0.78; }

.promo-preview__pin {
    display: inline-flex;
    align-items: center;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6d28d9;
}

.mud-theme-dark .promo-preview__pin { color: #c4b5fd; }
