/* ========================================
   ZINRAI Theme Styles
   Component styling using CSS variables
   ======================================== */

/* ========================================
   Base Layout
   ======================================== */
html, body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
   Sidebar / Navigation
   ======================================== */
.nav-container {
    background-color: var(--nav-bg);
    border-right: 1px solid var(--border-divider);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* Sidebar layout (.nav-container width + every .nav-container.collapsed.*
   override) and base styling for .logo-*, .nav-menu, .nav-item (+ hover/active)
   are owned by the scoped BackOffice/Layout/NavMenu.razor.css.

   The rules that remain in this file (.nav-icon, .nav-text, .nav-badge,
   .nav-submenu, .nav-footer, .collapse-btn, .logout-btn base styling below)
   are pending a broader sidebar-CSS cleanup tracked separately from ZN-327. */

.nav-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--nav-icon-color);
    transition: color 0.2s ease;
}

.nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 9999px;
    background-color: var(--badge-new-bg);
    color: var(--badge-new-text);
    text-transform: uppercase;
}

/* Submenu / Expandable Items */
.nav-item-expandable {
    position: relative;
}

.nav-item-expandable .nav-chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.nav-item-expandable.expanded .nav-chevron {
    transform: rotate(180deg);
}

/* External-link indicator — any nav item that opens in a new tab gets the
   standard "square + arrow exiting top-right" external-link glyph at the
   right edge, matching Anna's sidebar design. CSS-driven via the
   [target="_blank"] attribute selector so we don't have to add markup to
   every external <NavLink>. Collapsed sidebar hides it (no room beside icon).
   The icon inherits currentColor so it stays in sync with the link's hover /
   active state colors. */
.nav-item[target="_blank"]::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-left: auto;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M15 3h6v6'/><path d='M10 14L21 3'/><path d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M15 3h6v6'/><path d='M10 14L21 3'/><path d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/></svg>");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    opacity: 0.7;
}

.nav-container.collapsed .nav-item[target="_blank"]::after {
    display: none;
}

/* Submenu reveal animation lives in the inline <style> block in NavMenu.razor
   (uses max-height transition). These global rules just set the indentation
   and column layout; they purposely don't set display:none so the inline
   rules can drive the transition without fighting a hidden/shown toggle. */
.nav-submenu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 32px;
}

.nav-submenu.show {
    /* legacy compatibility — kept so any older code that toggles a .show class
       still works. The inline-style max-height rules handle the actual reveal. */
}

.nav-submenu .nav-item {
    padding: 8px 14px;
    font-size: 0.8125rem;
}

/* Navigation Footer */
.nav-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border-divider);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.collapse-btn,
.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--nav-item-text);
    background-color: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.collapse-btn:hover,
.logout-btn:hover {
    background-color: var(--nav-item-bg-hover);
    color: var(--nav-item-text-hover);
}

.logout-btn:hover {
    color: var(--color-error);
}

/* ========================================
   Main Layout
   ======================================== */
.backoffice-layout {
    display: flex;
    height: 100vh;
    background-color: var(--bg-body);
}

.sidebar {
    flex-shrink: 0;
    background-color: var(--nav-bg);
    transition: width 0.3s ease;
    height: 100%;
    overflow: hidden;
}

.sidebar.expanded {
    width: 256px;
}

.sidebar.collapsed {
    width: 68px;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Top Header */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-divider);
    gap: 24px;
    min-height: 70px;
}

.search-container {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

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

.search-input:focus {
    outline: none;
    border-color: var(--border-input-focus);
    background-color: var(--bg-input-focus);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
}

.header-btn:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.header-btn svg {
    width: 20px;
    height: 20px;
}

.header-btn svg path {
    stroke: currentColor;
}

.notification-btn {
    position: relative;
}

/* ZN-1137: the bell is nudged up from the shared 20px header-icon size so the 16px badge reads
   as an annotation on it rather than a second icon of similar weight. Scoped to this button
   only — the language and theme icons stay at 20px. Needed as CSS because `.header-btn svg`
   above sets an explicit size, which beats the SVG's own width/height attributes. */
.notification-btn svg {
    width: 22px;
    height: 22px;
}

/* Header notification count badge. ZN-1137: this is the ONE home for its size and shape —
   MainLayout.razor.css used to carry a second, conflicting rule for the same element, and
   between them the badge rendered as an oval.

   Sized to read as a small annotation ON the 22px bell rather than a second icon competing
   with it: 16px circle, 10px semibold, tucked tightly over the upper-right corner with a
   negative offset so it overlaps the glyph instead of sitting beside it. Circular, not a pill —
   width and height are pinned equal with no horizontal padding, so the two-character "9+"
   cannot stretch it. MainLayout caps the label at "9+", so a fixed box is safe.

   The ring matches the header background so the badge reads as lifted off the icon; it is a
   border rather than a shadow so it stays crisp at this size. */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    min-width: 16px;
    height: 16px;
    padding: 0;
    box-sizing: border-box;
    background-color: var(--notification-dot);
    border: 1.5px solid var(--bg-header, var(--bg-card));
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

.header-divider {
    width: 1px;
    height: 32px;
    background-color: var(--border-divider);
    margin: 0 8px;
}

.header-user-id {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-menu-trigger {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 9999px;
}

.user-menu-trigger .user-avatar {
    width: 36px;
    height: 36px;
}

.user-account-menu {
    min-width: 220px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 8px;
}

.user-account-menu .mud-list {
    padding: 0;
}

.user-menu-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 8px 8px;
}

.user-menu-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-account-menu .mud-menu-item {
    border-radius: 8px;
}

.user-account-menu .mud-menu-item .mud-icon-root,
.user-account-menu .mud-menu-item .mud-menu-item-icon {
    color: var(--text-secondary) !important;
}

.user-account-menu .mud-menu-item:hover .mud-icon-root,
.user-account-menu .mud-menu-item:hover .mud-menu-item-icon {
    color: var(--text-primary) !important;
}

.user-account-menu .mud-menu-item:hover {
    background-color: var(--bg-card-hover);
}

.user-account-menu .user-menu-logout {
    color: var(--color-error);
}

.user-account-menu .user-menu-logout .mud-icon-root,
.user-account-menu .user-menu-logout .mud-menu-item-icon {
    color: var(--color-error) !important;
}

.user-account-menu .user-menu-logout:hover {
    background-color: var(--color-error-bg);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-profile:hover {
    background-color: var(--bg-card-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Content Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.content-area {
    max-width: 100%;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
}

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

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 4px 0 0;
}

.card-body {
    color: var(--text-primary);
}

.card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-divider);
}

/* Stat Cards (Dashboard) */
.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
}

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

.stat-card-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.stat-card-icon {
    width: 24px;
    height: 24px;
    color: var(--text-tertiary);
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-top: 8px;
}

.stat-card-change.positive {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.stat-card-change.negative {
    background-color: var(--color-error-bg);
    color: var(--color-error);
}

/* Volume Card (Two-column) */
.volume-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
}

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

.volume-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.volume-card-action {
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.volume-card-action:hover {
    color: var(--text-primary);
}

.volume-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.volume-stat {
    text-align: left;
}

.volume-stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.volume-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.volume-divider {
    width: 1px;
    background-color: var(--border-divider);
}

.volume-total {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-divider);
}

.volume-total-label {
    font-size: 0.875rem;
    color: var(--accent-secondary);
    font-weight: 500;
}

/* Ratio Card */
.ratio-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
}

.ratio-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px;
}

.ratio-stats {
    display: flex;
    justify-content: space-between;
}

.ratio-stat {
    text-align: center;
}

.ratio-stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.ratio-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Big Number Card */
.big-number-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
    text-align: center;
}

.big-number-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px;
}

.big-number-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

/* Reward Points Card */
.reward-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
    text-align: center;
}

.reward-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.reward-card-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.reward-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: var(--color-success);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.reward-card-btn:hover {
    background-color: var(--color-success);
    filter: brightness(1.1);
}

/* ========================================
   Donut/Progress Charts
   ======================================== */
.chart-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
}

.chart-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px;
}

.chart-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 32px;
}

.donut-chart {
    position: relative;
    width: 120px;
    height: 120px;
}

.donut-chart svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-chart circle {
    fill: none;
    stroke-width: 12;
}

.donut-chart .donut-bg {
    stroke: var(--border-divider);
}

.donut-chart .donut-fill {
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.donut-chart .donut-fill.cyan {
    stroke: var(--chart-cyan);
}

.donut-chart .donut-fill.teal {
    stroke: var(--chart-teal);
}

.donut-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-chart-percent {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-stat {
    text-align: center;
}

.chart-stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.chart-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Chart Legend */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.chart-legend-dot.cyan {
    background-color: var(--chart-cyan);
}

.chart-legend-dot.teal {
    background-color: var(--chart-teal);
}

/* ========================================
   Tables
   ======================================== */
.data-table-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.data-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-divider);
}

.data-table-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.data-table-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-table-show {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.data-table-show select {
    padding: 6px 8px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.data-table-search {
    position: relative;
}

.data-table-search input {
    padding: 6px 12px;
    width: 160px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.data-table-search input::placeholder {
    color: var(--text-tertiary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 20px;
    text-align: left;
    font-size: 0.875rem;
}

.data-table th {
    background-color: var(--bg-table-header);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.data-table td {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-divider);
}

.data-table tbody tr {
    background-color: var(--bg-table-row);
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: var(--bg-table-row-hover);
}

.data-table tbody tr:nth-child(even) {
    background-color: var(--bg-table-row-alt);
}

.data-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.data-table-action-btn {
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.data-table-action-btn:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

/* Status Badge in Table */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.loading {
    background-color: var(--color-info-bg);
    color: var(--color-info);
}

.status-badge.success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.status-badge.warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

.status-badge.error {
    background-color: var(--color-error-bg);
    color: var(--color-error);
}

/* Table Pagination */
.data-table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border-divider);
}

.data-table-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background-color: var(--accent-primary);
    color: white;
}

.pagination-ellipsis {
    padding: 0 4px;
    color: var(--text-tertiary);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}

.btn-primary:hover {
    background-color: var(--btn-primary-bg-hover);
}

.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--btn-secondary-border);
}

.btn-secondary:hover {
    background-color: var(--btn-secondary-bg-hover);
}

.btn-danger {
    background-color: var(--btn-danger-bg);
    color: var(--btn-danger-text);
}

.btn-danger:hover {
    background-color: var(--btn-danger-bg-hover);
}

.btn-success {
    background-color: var(--btn-success-bg);
    color: var(--btn-success-text);
}

.btn-success:hover {
    background-color: var(--btn-success-bg-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1rem;
}

/* ========================================
   Form Inputs
   ======================================== */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

/* Native date-picker calendar icon: invert in dark mode so it's visible against
   the dark input background. Global because :root[data-theme="dark"] doesn't
   reliably traverse Blazor's scoped CSS attribute boundary. */
.form-input::-webkit-calendar-picker-indicator,
.field-input::-webkit-calendar-picker-indicator {
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.15s;
}

.form-input::-webkit-calendar-picker-indicator:hover,
.field-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

:root[data-theme="dark"] .form-input::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] .field-input::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(0.85);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-input-focus);
    background-color: var(--bg-input-focus);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 16px;
}

/* ========================================
   Modals / Dialogs
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-modal);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-divider);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-divider);
}

/* ========================================
   Loading States
   ======================================== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1rem;
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-divider);
    border-top-color: var(--loading-spinner);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   Compensation Plan Modal
   ======================================== */
/* Geometry is written as .mud-dialog.comp-plan-modal (two classes) on purpose:
   MudBlazor's own .mud-dialog-width-xl / .mud-dialog rules ship in
   BackOffice.styles.css, which index.html loads AFTER zinrai-theme.css, so a
   single-class selector here ties on specificity and LOSES on source order. */
.mud-dialog.comp-plan-modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-card);
    /* Full width is deliberate and left to MudBlazor's MaxWidth.ExtraLarge
       (.mud-dialog-width-xl = max-width:1920px) + FullWidth: the real document
       renders in a PDF viewer that spends the width on its page + thumbnail
       sidebar, so a narrower cap here would shrink the page rather than remove
       dead space. */
    width: 100%;
    /* Cap the whole dialog to the viewport and lay it out as a flex column so
       the document viewer (the flexible region) shrinks instead of pushing the
       acceptance checkboxes and action buttons below the fold (ZN: modal
       required scrolling to reach the checkboxes on short screens). */
    display: flex;
    flex-direction: column;
    /* Claim the available height AND cap at the same value, so the viewer's
       flex-grow has free space to take while the dialog never exceeds the
       viewport. Both are needed: height alone would be clamped by MudBlazor's
       own max-height, and max-height alone lets the dialog size to content.
       dvh matches MudBlazor's own unit and accounts for mobile browser chrome.
       A literal inset is used rather than MudBlazor's var(--mud-appbar-height):
       that variable is set at runtime and is undefined here, which would make
       the whole calc() invalid and silently drop the height entirely. */
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
    /* MudBlazor's .mud-dialog sets overflow-y:auto. Left on, the DIALOG itself
       scrolls, which is exactly what hid the second checkbox — the checkbox was
       rendered but below the dialog's own scroll fold. The viewer shrinks to
       absorb the height instead. */
    overflow-y: hidden;
}

/* Header text + viewer + checkboxes. Only the viewer flexes; everything else
   stays its natural height, so both checkboxes are always in view. This region
   does not scroll at normal viewport heights — the viewer absorbs the height
   difference instead, otherwise the second checkbox ends up below the fold.
   'auto' rather than 'hidden' so that on a very short viewport, where even the
   viewer's 200px floor cannot fit, the checkboxes stay REACHABLE by scrolling
   rather than being clipped away with no way to get to them. */
.comp-plan-modal .mud-dialog-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    /* !important: mudblazor-overrides.css and MudBlazor's own .mud-dialog-content
       rules load later and set padding/overflow on this element. */
    min-height: 0 !important;
    overflow-y: auto !important;
}

/* Title and actions must not shrink — keep them pinned. */
.comp-plan-modal .mud-dialog-title,
.comp-plan-modal .mud-dialog-actions {
    flex: 0 0 auto;
}

.comp-plan-modal__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comp-plan-modal__warning {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--color-warning);
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-weight: 600;
}

.comp-plan-modal__label {
    margin-top: 6px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comp-plan-modal__viewer {
    width: 100%;
    /* Fill the remaining dialog height and shrink to absorb whatever the fixed
       rows need, so both checkboxes and the buttons fit without scrolling. The
       floor is deliberately small (was 420px): flex items refuse to shrink below
       min-height, so too high a floor overflows the dialog and pushes the second
       checkbox below the fold — the bug this replaces. 200px still leaves the
       PDF toolbar plus a readable band, and only binds on very short viewports.
       No max-height: the document scrolls internally, so a ceiling would shrink
       the reading area and hand the leftover height to empty dialog padding. */
    flex: 1 1 auto;
    min-height: 200px;
    border: 1px solid var(--border-divider);
    border-radius: 8px;
    background: var(--bg-card);
}

/* Non-viewer rows are fixed-height so the viewer is the only flex item that
   grows; keep their margins tight so the reading area gets the height. */
.comp-plan-modal__warning,
.comp-plan-modal__label,
.comp-plan-modal__actions-row,
.comp-plan-modal__checkbox {
    flex: 0 0 auto;
}

.comp-plan-modal__actions-row {
    margin-top: 10px;
    margin-bottom: 6px;
}

.comp-plan-modal__later-btn {
    color: var(--text-primary) !important;
    border: 1px solid var(--border-divider) !important;
    border-radius: 8px;
    padding-left: 12px;
    padding-right: 12px;
}

.comp-plan-modal__later-btn:hover {
    background-color: var(--bg-card-hover) !important;
}

.comp-plan-modal__accept-btn {
    background-color: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    border-radius: 8px;
    padding-left: 16px;
    padding-right: 16px;
    font-weight: 600;
}

.comp-plan-modal__accept-btn:hover:not(:disabled) {
    background-color: var(--btn-primary-bg-hover) !important;
}

/* Note: disabled-state styling for .comp-plan-modal__accept-btn lives in
   mudblazor-overrides.css because it targets MudBlazor internals
   (.mud-button-root, .mud-button-disabled). */

/* ========================================
   WhatsApp Support Prompt Modal
   ======================================== */
.wa-support-modal__btn--skip {
    color: var(--text-primary) !important;
    border: 1px solid var(--border-divider) !important;
    border-radius: 8px;
    padding-left: 16px;
    padding-right: 16px;
    background-color: transparent !important;
}

.wa-support-modal__btn--skip:hover:not(:disabled) {
    background-color: var(--bg-card-hover) !important;
    border-color: var(--accent-primary) !important;
}

.wa-support-modal__btn--confirm {
    background-color: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    border-radius: 8px;
    padding-left: 16px;
    padding-right: 16px;
    font-weight: 600;
}

.wa-support-modal__btn--confirm:hover:not(:disabled) {
    background-color: var(--btn-primary-bg-hover) !important;
}

.comp-plan-modal__checkbox {
    margin-top: 2px;
}

/* MudBlazor pads its checkbox button generously; trim it so both acceptance
   rows sit compactly under the viewer instead of competing with it for height. */
.comp-plan-modal__checkbox .mud-button-root.mud-icon-button {
    padding: 6px;
}

.comp-plan-modal__empty {
    padding: 10px;
    border: 1px solid var(--border-divider);
    border-radius: 8px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.comp-plan-modal__error {
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 8px;
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

/* ========================================
   Login Page
   ======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-body);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-dialog {
    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-dialog .icon-circle {
    width: 64px;
    height: 64px;
    background-color: var(--accent-primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.login-dialog .icon-circle svg path {
    stroke: var(--accent-primary);
}

.login-dialog .dialog-content {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-dialog .dialog-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.login-dialog .dialog-description {
    color: var(--text-secondary);
    margin: 0;
}

.login-dialog .form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.login-dialog .required {
    color: var(--color-error);
}

.login-dialog .form-input {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-primary);
    box-sizing: border-box;
}

.login-dialog .form-input::placeholder {
    color: var(--text-tertiary);
}

.login-dialog .form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.login-dialog .form-input:disabled {
    background-color: var(--bg-table-header);
    opacity: 0.7;
}

.login-dialog .error-message {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.login-dialog .login-button {
    width: 100%;
    padding: 0.875rem;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.login-dialog .login-button:hover {
    background-color: var(--accent-primary-hover);
}

.login-dialog .login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Dashboard Page
   ======================================== */
.dashboard-page {
    padding: 0;
}

.page-header {
    margin-bottom: 24px;
}


.page-header .page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* Responsive Grid */
@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .dashboard-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-grid,
    .dashboard-grid-2,
    .dashboard-grid-3 {
        grid-template-columns: 1fr;
    }
    
    .top-header {
        padding: 12px 16px;
    }
    
    .search-container {
        display: none;
    }
    
    .header-divider,
    .user-name,
    .header-user-id {
        display: none;
    }
    
    .main-content {
        padding: 16px;
    }
}

/* ========================================
   MudBlazor Overrides
   ======================================== */
.mud-theme-primary {
    background-color: var(--accent-primary) !important;
}

.mud-primary-text {
    color: var(--accent-primary) !important;
}

.mud-dialog {
    background-color: var(--bg-modal) !important;
}

.mud-dialog-title {
    color: var(--text-primary) !important;
}

.mud-input-outlined {
    --mud-palette-text-primary: var(--text-primary) !important;
}

.mud-snackbar {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* MudTable overrides */
.mud-table {
    background-color: var(--bg-card) !important;
}

.mud-table-head {
    background-color: var(--bg-table-header) !important;
}

.mud-table-row {
    background-color: var(--bg-table-row) !important;
}

.mud-table-row:hover {
    background-color: var(--bg-table-row-hover) !important;
}

/* ============ ZN-461 VIP Reward Tracker popup ============ */
.vip-reward-popup {
    max-width: 520px;
    width: 100%;
}

/* ZN-1350: geometry is written as .mud-dialog.vip-reward-popup (two classes)
   on purpose, same trick as .mud-dialog.comp-plan-modal above — MudBlazor's
   own .mud-dialog rules ship in a stylesheet that index.html loads AFTER
   zinrai-theme.css, so a single-class selector here ties .mud-dialog at
   0,1,0 and LOSES on source order. --mud-default-borderradius is never
   overridden in this repo, so without this the dialog root falls back to
   MudBlazor's smaller default radius while .vip-reward-popup__hero below
   uses an explicit 8px 8px 0 0 — the mismatched arcs let the white
   --bg-modal dialog surface paint through as a crescent at the top corners
   in light mode. 8px here matches the hero exactly. Do NOT fix this with
   overflow:hidden instead: .mud-dialog needs its own overflow-y:auto, or
   the ZN-637 redeem-variant content can be clipped below the fold on short
   viewports. */
.mud-dialog.vip-reward-popup {
    border-radius: 8px;
}

.vip-reward-popup .mud-dialog-title {
    padding: 0 !important;
}

.vip-reward-popup__hero {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-tint));
    border-radius: 8px 8px 0 0;
    padding: 36px 24px;
    text-align: center;
    overflow: hidden;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.vip-reward-popup__eyebrow {
    font-size: 0.7rem;
    font-variant: small-caps;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-on-accent-soft);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.vip-reward-popup__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-on-accent);
    line-height: 1.2;
}

/* ZN-1350: the close (X) button is MudBlazor's own .mud-button-close (which
   also carries .mud-icon-button) and nothing in this repo styles
   .mud-button-close directly, so it inherits mudblazor-overrides.css:411's
   .mud-icon-button rule — color: var(--text-secondary), a mid-grey in light
   mode, well under 4.5:1 against the .vip-reward-popup__hero gradient,
   effectively invisible. !important is required on the colour declarations
   below to beat mudblazor-overrides.css:411/415's own !important rules. Scoped to
   .vip-reward-popup on purpose: about a dozen other dialogs use
   CloseButton="true" on the plain white --bg-modal surface where
   --text-secondary reads correctly (13 sites enumerated at ZN-1350 review
   time), and .mud-icon-button is also emitted by MudBlazor internals we never
   write by hand — table pagination arrows, autocomplete/select clear icons,
   snackbar close — so a global change here would regress all of them. (That
   second group is inferred from MudBlazor's own markup, not enumerated:
   `MudIconButton` itself has zero hits in BackOffice source.) --text-on-accent and --overlay-on-accent-light are
   both defined identically in light and dark mode. */
.vip-reward-popup .mud-button-close {
    color: var(--text-on-accent) !important;
}

.vip-reward-popup .mud-button-close:hover {
    background-color: var(--overlay-on-accent-light) !important;
}

.vip-reward-popup .mud-button-close:focus-visible {
    outline: 2px solid var(--text-on-accent);
    outline-offset: 2px;
}

.vip-reward-popup .mud-dialog-content {
    padding: 24px 24px 8px;
}

.vip-reward-popup__intro {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.vip-reward-popup__card {
    background-color: var(--bg-card-hover);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
}

.vip-reward-popup__counter {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
}

.vip-reward-popup__counter-current {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1;
}

.vip-reward-popup__counter-divider {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1;
}

.vip-reward-popup__counter-target {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-primary-tint);
    line-height: 1;
}

.vip-reward-popup__counter-label {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.vip-reward-popup__progress {
    height: 10px;
    background-color: var(--accent-primary-light);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.vip-reward-popup__progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-primary-bright));
    transition: width 0.4s ease;
    min-width: 4px;
}

.vip-reward-popup__progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vip-reward-popup__helper {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.vip-reward-popup__cta {
    width: 100%;
    border-radius: 8px !important;
    font-weight: 600;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-primary-bright)) !important;
    color: var(--btn-primary-text) !important;
    padding: 10px 0 !important;
}

.vip-reward-popup__cta:hover:not(:disabled) {
    background: linear-gradient(90deg, var(--accent-primary-hover), var(--accent-primary)) !important;
}

.vip-reward-popup .mud-dialog-actions {
    padding: 16px 24px 24px;
}

/* ZN-637: Redeem-now variant */
.vip-reward-popup__actions-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.vip-reward-popup__secondary {
    color: var(--text-muted) !important;
    font-size: 0.85rem !important;
}

.vip-reward-popup__secondary:hover {
    color: var(--text-primary) !important;
}

.vip-reward-popup__disclosure {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
    background-color: var(--bg-card-hover);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
}

.vip-reward-popup__result {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.vip-reward-popup__result--success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.vip-reward-popup__result--error {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}
