/* ==========================================================================
   QrBiteHub Staff Theme System
   Light (default) and Dark themes with CSS variables
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

/* ==========================================================================
   FONT VARIABLES
   ========================================================================== */
:root {
    --font-display: 'Plus Jakarta Sans', 'DM Sans', sans-serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-arabic: 'IBM Plex Sans Arabic', 'DM Sans', sans-serif;
}

/* ==========================================================================
   LIGHT THEME (Default)
   Variables cascade from html to all descendants
   ========================================================================== */
html,
html[data-theme="light"] {
    /* Backgrounds */
    --bg: #F7FAFA;
    --bg-card: #FFFFFF;
    --bg-elevated: #F3F4F6;
    --bg-hover: #E5E7EB;
    --bg-deep: #F0F2F4;

    /* Borders & Dividers */
    --border: #E5E7EB;
    --border-hover: #D1D5DB;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;

    /* Brand Colors */
    --primary: #0d124c;
    --primary-light: rgba(13, 18, 76, 0.1);
    --accent: #f58524;
    --accent-light: #ff9a3c;
    --accent-subtle: rgba(245, 133, 36, 0.08);
    --accent-glow: rgba(245, 133, 36, 0.15);
    --gradient-end: #d97706;

    /* Status Colors */
    --success: #10B981;
    --success-bg: #D1FAE5;
    --success-text: #065F46;
    --danger: #EF4444;
    --danger-bg: #FEE2E2;
    --danger-text: #991B1B;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    --warning-text: #92400E;

    /* Shadows */
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
    --glow-accent: 0 4px 20px rgba(245, 133, 36, 0.2);

    /* Radius */
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Button specific */
    --btn-cta-bg: linear-gradient(135deg, #f58524 0%, #e07620 50%, #c96a1c 100%);
    --btn-cta-bg-hover: linear-gradient(135deg, #ff9a3c 0%, #f58524 50%, #e07620 100%);
    --btn-cta-text: white;
    --btn-cta-shadow: 0 2px 4px rgba(245, 133, 36, 0.2), 0 4px 12px rgba(245, 133, 36, 0.15);
    --btn-cta-shadow-hover: 0 4px 8px rgba(245, 133, 36, 0.3), 0 8px 24px rgba(245, 133, 36, 0.2);

    --btn-danger-bg: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    --btn-danger-border: #FECACA;
    --btn-danger-text: #DC2626;
    --btn-danger-bg-hover: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);

    /* Input specific */
    --input-bg: var(--bg-card);
    --input-border: var(--border);
    --input-focus-border: var(--accent);
    --input-focus-shadow: 0 0 0 3px rgba(245, 133, 36, 0.12);

    /* Scrollbar */
    --scrollbar-track: var(--bg-elevated);
    --scrollbar-thumb: var(--border);
    --scrollbar-thumb-hover: var(--text-muted);

    /* Selected state */
    --selected-bg: rgba(245, 133, 36, 0.08);
    --selected-border: rgba(245, 133, 36, 0.25);

    /* Logo/Avatar gradient */
    --avatar-gradient: linear-gradient(135deg, #1e2a5e 0%, #0d124c 100%);

    /* Topbar */
    --topbar-bg: var(--bg-card);
    --topbar-border: var(--border);

    /* Grid pattern (none for light) */
    --grid-pattern: none;
}

/* ==========================================================================
   DARK THEME
   Applied when html[data-theme="dark"] - cascades to all descendants
   ========================================================================== */
html[data-theme="dark"] {
    /* Backgrounds */
    --bg: #0f1117;
    --bg-card: #181b23;
    --bg-elevated: #1f232e;
    --bg-hover: #252a38;
    --bg-deep: #0f1117;

    /* Borders & Dividers */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Text */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Brand Colors */
    --primary: #0d124c;
    --primary-light: rgba(13, 18, 76, 0.3);
    --accent: #f58524;
    --accent-light: #ff9a3c;
    --accent-subtle: rgba(245, 133, 36, 0.08);
    --accent-glow: rgba(245, 133, 36, 0.15);
    --gradient-end: #d97706;

    /* Status Colors */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --success-text: #4ade80;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --danger-text: #f87171;
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-text: #fbbf24;

    /* Shadows */
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --glow-accent: 0 0 20px rgba(245, 133, 36, 0.2);

    /* Button specific */
    --btn-cta-bg: linear-gradient(135deg, #f58524 0%, #e07620 100%);
    --btn-cta-bg-hover: linear-gradient(135deg, #ff9a3c 0%, #f58524 100%);
    --btn-cta-text: #0f1117;
    --btn-cta-shadow: 0 2px 8px rgba(245, 133, 36, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    --btn-cta-shadow-hover: 0 4px 20px rgba(245, 133, 36, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);

    --btn-danger-bg: rgba(239, 68, 68, 0.12);
    --btn-danger-border: rgba(239, 68, 68, 0.2);
    --btn-danger-text: #f87171;
    --btn-danger-bg-hover: rgba(239, 68, 68, 0.2);

    /* Input specific */
    --input-bg: #0f1117;
    --input-border: rgba(255, 255, 255, 0.06);
    --input-focus-border: #f58524;
    --input-focus-shadow: 0 0 0 3px rgba(245, 133, 36, 0.08);

    /* Scrollbar */
    --scrollbar-track: #0f1117;
    --scrollbar-thumb: #252a38;
    --scrollbar-thumb-hover: #71717a;

    /* Selected state */
    --selected-bg: rgba(245, 133, 36, 0.08);
    --selected-border: rgba(245, 133, 36, 0.2);

    /* Logo/Avatar gradient */
    --avatar-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    /* Topbar */
    --topbar-bg: linear-gradient(180deg, #181b23 0%, rgba(24, 27, 35, 0.95) 100%);
    --topbar-border: rgba(255, 255, 255, 0.06);

    /* Grid pattern */
    --grid-pattern:
        linear-gradient(rgba(255,255,255,0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.01) 1px, transparent 1px);
}

/* ==========================================================================
   BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.staff-theme {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

[dir="rtl"] body.staff-theme,
body.staff-theme[dir="rtl"] {
    font-family: var(--font-arabic);
}

/* ==========================================================================
   DISPLAY TYPOGRAPHY - Distinctive headings
   ========================================================================== */
body.staff-theme h1,
body.staff-theme h2,
body.staff-theme .display-text {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

body.staff-theme h1 {
    font-weight: 700;
}

body.staff-theme h2 {
    font-weight: 600;
}

/* KPI Values - Bold display font */
body.staff-theme .kpi-value,
body.staff-theme .stat-value,
body.staff-theme .metric-value {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Grid pattern overlay for dark theme */
body.staff-theme::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: var(--grid-pattern);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: 0;
}

/* ==========================================================================
   THEME-BASED LOGO VISIBILITY
   Logo switching controlled by html[data-theme] - no Blazor needed
   ========================================================================== */
html:not([data-theme="dark"]) .brand-logo-dark {
    display: none;
}
html:not([data-theme="dark"]) .brand-logo-light {
    display: block;
}
html[data-theme="dark"] .brand-logo-light {
    display: none;
}
html[data-theme="dark"] .brand-logo-dark {
    display: block;
}

/* ==========================================================================
   THEME TOGGLE ICON VISIBILITY
   Show sun in dark mode (to switch to light), moon in light mode (to switch to dark)
   ========================================================================== */
html:not([data-theme="dark"]) .sun-icon {
    display: none !important;
}
html:not([data-theme="dark"]) .moon-icon {
    display: block !important;
}
html[data-theme="dark"] .sun-icon {
    display: block !important;
}
html[data-theme="dark"] .moon-icon {
    display: none !important;
}

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.staff-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    height: 60px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.staff-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.staff-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent) 0%, #d97706 100%);
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.5px;
    box-shadow: var(--glow-accent);
}

.staff-titles h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.staff-titles small {
    font-size: 12px;
    color: var(--text-muted);
}

.staff-titles small strong {
    color: var(--text-secondary);
}

.staff-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   ICON BUTTONS
   ========================================================================== */
.icon-btn {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.icon-btn.accent:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--glow-accent);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* Primary CTA Button */
.btn.cta {
    background: var(--btn-cta-bg);
    border: none;
    color: var(--btn-cta-text);
    font-weight: 700;
    box-shadow: var(--btn-cta-shadow);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.btn.cta:hover {
    background: var(--btn-cta-bg-hover);
    box-shadow: var(--btn-cta-shadow-hover);
    transform: translateY(-2px);
}

.btn.cta:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(245, 133, 36, 0.3);
}

/* Small button variant */
.btn.small {
    padding: 7px 12px;
    font-size: 12px;
    border-radius: 8px;
}

/* Secondary/Ghost button */
.btn.secondary,
.btn.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn.secondary:hover,
.btn.ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Danger button */
.btn.danger {
    background: var(--btn-danger-bg);
    border: 1px solid var(--btn-danger-border);
    color: var(--btn-danger-text);
}

.btn.danger:hover {
    background: var(--btn-danger-bg-hover);
    border-color: var(--danger);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

/* Outline variant */
.btn.outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}

.btn.outline:hover {
    background: var(--accent-subtle);
    border-color: var(--accent-light);
    color: var(--accent-light);
}

/* ==========================================================================
   LANGUAGE SELECTOR
   ========================================================================== */
.lang-selector {
    position: relative;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.lang-toggle:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.lang-toggle .globe-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.lang-toggle .lang-code {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.lang-toggle .chevron-icon {
    width: 12px;
    height: 12px;
    opacity: 0.5;
    transition: transform 0.2s;
}

.lang-selector.open .lang-toggle .chevron-icon {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px;
    min-width: 170px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.lang-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.lang-option.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.lang-option .check-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
    flex-shrink: 0;
}

.lang-option .lang-name {
    flex: 1;
}

.lang-option .lang-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.lang-option.active .lang-badge {
    background: var(--accent-subtle);
    border-color: rgba(245, 133, 36, 0.2);
    color: var(--accent);
}

.lang-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}

/* Legacy lang-btn (for backwards compatibility) */
.lang-btn {
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

/* ==========================================================================
   USER BUTTON
   ========================================================================== */
.user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--avatar-gradient);
    color: white;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 600;
}

.uname {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ==========================================================================
   THEME TOGGLE
   ========================================================================== */
.theme-toggle {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* ==========================================================================
   MASTER-DETAIL LAYOUT
   ========================================================================== */
.master-detail-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    padding: 16px 20px;
    min-height: calc(100vh - 60px);
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   MASTER PANEL (LEFT)
   ========================================================================== */
.master-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.master-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.master-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.master-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-deep);
    transition: all 0.2s ease;
}

.master-search:focus-within {
    border-color: var(--accent);
    box-shadow: var(--input-focus-shadow);
}

.master-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.master-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}

.master-search input::placeholder {
    color: var(--text-muted);
}

.master-filters {
    padding: 0 14px 14px;
}

.filter-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    font-family: inherit;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

[data-theme="dark"] .filter-select,
.staff-shell.dark-theme .filter-select,
.dark-theme .filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.master-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 10px;
}

.master-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.master-item:hover {
    background: var(--bg-elevated);
}

.master-item.selected {
    background: var(--selected-bg);
    border-color: var(--selected-border);
}

.master-item.selected .item-details strong {
    color: var(--accent-light);
}

.item-thumb {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    overflow: hidden;
    border: 1px solid var(--border);
}

.item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-details {
    flex: 1;
    min-width: 0;
}

.item-details strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.item-details small {
    color: var(--text-muted);
    font-size: 11px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* ==========================================================================
   DETAIL PANEL (RIGHT)
   ========================================================================== */
.detail-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    box-shadow: var(--shadow-card);
}

.detail-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.detail-empty h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.detail-empty p {
    margin-bottom: 24px;
    max-width: 300px;
    line-height: 1.6;
}

/* ==========================================================================
   CARDS
   ========================================================================== */
.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

.card-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

.spacer {
    flex: 1;
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge.ok {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge.bad {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.count-badge {
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(245, 133, 36, 0.15);
}

/* ==========================================================================
   FORMS
   ========================================================================== */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.input:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: var(--input-focus-shadow);
}

.input::placeholder {
    color: var(--text-muted);
}

textarea.input {
    resize: vertical;
    min-height: 75px;
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
    cursor: pointer;
}

[data-theme="dark"] select.input,
.staff-shell.dark-theme select.input,
.dark-theme select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ==========================================================================
   IMAGE UPLOAD
   ========================================================================== */
.image-upload-compact {
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-preview-small {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

.image-preview-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius);
    background: var(--bg-deep);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* ==========================================================================
   INLINE FORM
   ========================================================================== */
.inline-form {
    padding: 18px;
    background: var(--bg-deep);
    border-radius: var(--radius);
    margin-bottom: 18px;
    border: 1px solid var(--border);
}

/* ==========================================================================
   SUBCATEGORIES LIST
   ========================================================================== */
.subcats-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.subcat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    transition: all 0.15s ease;
}

.subcat-row:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.subcat-thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg-deep);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.subcat-info {
    flex: 1;
    min-width: 0;
}

.subcat-info strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.subcat-info small {
    color: var(--text-muted);
    font-size: 11px;
}

.subcat-actions {
    display: flex;
    gap: 5px;
}

.subcat-actions .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

/* ==========================================================================
   TRANSLATION SECTION
   ========================================================================== */
.translation-section {
    margin-top: 18px;
    padding: 18px;
    background: var(--bg-deep);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.translation-section .section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.lang-tabs {
    display: flex;
    gap: 8px;
}

.lang-tab {
    padding: 6px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.lang-tab:hover {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.lang-tab.active {
    background: var(--accent-subtle);
    border-color: rgba(245, 133, 36, 0.3);
    color: var(--accent);
}

/* ==========================================================================
   SCROLLBAR
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
    .master-detail-layout {
        grid-template-columns: 1fr;
    }

    .master-panel {
        max-height: 400px;
    }
}

@media (max-width: 600px) {
    .staff-topbar {
        padding: 8px 12px;
    }

    .staff-titles h1 {
        font-size: 15px;
    }

    .staff-titles small {
        display: none;
    }

    .master-detail-layout {
        padding: 12px;
        gap: 12px;
    }
}

/* ==========================================================================
   RTL SUPPORT
   Uses [dir="rtl"] attribute selector for standard compliance
   ========================================================================== */
[dir="rtl"] body.staff-theme,
body.staff-theme[dir="rtl"] {
    text-align: right;
}

/* Language selector RTL */
[dir="rtl"] .lang-selector {
    direction: rtl;
}

[dir="rtl"] .lang-toggle {
    flex-direction: row-reverse;
}

[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

[dir="rtl"] .lang-option {
    flex-direction: row-reverse;
    text-align: right;
}

/* Select dropdown arrow position for RTL */
[dir="rtl"] .filter-select,
[dir="rtl"] select.input {
    background-position: left 12px center;
    padding-left: 38px;
    padding-right: 14px;
}

/* Form layout adjustments for RTL */
[dir="rtl"] .form-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .card-footer {
    flex-direction: row-reverse;
}

[dir="rtl"] .subcat-actions {
    flex-direction: row-reverse;
}

/* Master-detail layout adjustment */
[dir="rtl"] .master-detail-layout {
    direction: rtl;
}

/* Icon button hover for delete in RTL */
[dir="rtl"] .subcat-row {
    flex-direction: row-reverse;
}

/* Status dot position */
[dir="rtl"] .master-item {
    flex-direction: row-reverse;
}

/* Badge positioning */
[dir="rtl"] .card-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .master-header {
    flex-direction: row-reverse;
}

/* Search input */
[dir="rtl"] .master-search {
    flex-direction: row-reverse;
}

[dir="rtl"] .master-search input {
    text-align: right;
}

/* Button icon gaps */
[dir="rtl"] .btn {
    flex-direction: row-reverse;
}

/* User button */
[dir="rtl"] .user-btn {
    flex-direction: row-reverse;
}

/* Image upload */
[dir="rtl"] .image-upload-compact {
    flex-direction: row-reverse;
}

[dir="rtl"] .upload-btn {
    flex-direction: row-reverse;
}

/* Text alignment for item details */
[dir="rtl"] .item-details {
    text-align: right;
}

[dir="rtl"] .subcat-info {
    text-align: right;
}

/* Inline form button alignment */
[dir="rtl"] .inline-form > div:last-child {
    justify-content: flex-start;
}

/* Detail empty state */
[dir="rtl"] .detail-empty {
    text-align: center;
}

/* Translation section */
[dir="rtl"] .lang-tabs {
    flex-direction: row-reverse;
}

/* Scrollbar for RTL */
[dir="rtl"] ::-webkit-scrollbar {
    direction: ltr;
}

/* ==========================================================================
   FLOATING ACTION BUTTON (FAB)
   ========================================================================== */
.fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--gradient-end) 100%);
    color: white;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.fab .fab-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--gradient-end) 0%, var(--accent) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fab:hover .fab-bg {
    opacity: 1;
}

.fab svg {
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.fab:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 40px var(--accent-glow), 0 0 0 4px rgba(245, 133, 36, 0.15);
}

.fab:hover svg {
    transform: rotate(90deg);
}

.fab:active {
    transform: translateY(-2px) scale(1.02);
}

/* RTL support for FAB */
[dir="rtl"] .fab {
    right: auto;
    left: 28px;
}

/* Responsive FAB - move above mobile bottom nav */
@media (max-width: 1024px) {
    .fab {
        bottom: 90px; /* 70px mobile nav + 20px spacing */
        right: 20px;
        width: 56px;
        height: 56px;
    }

    [dir="rtl"] .fab {
        right: auto;
        left: 20px;
    }
}

@media (max-width: 480px) {
    .fab {
        bottom: 85px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    [dir="rtl"] .fab {
        right: auto;
        left: 16px;
    }
}

/* ==========================================================================
   ENHANCED CARD HOVER EFFECTS
   Add .card-hover class to any card for elevation on hover
   ========================================================================== */
.card-hover {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), var(--shadow-card);
}

html[data-theme="dark"] .card-hover:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-hover);
}

.card-hover:active {
    transform: translateY(-2px);
}

/* Subtle hover variant */
.card-hover-subtle {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-hover-subtle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

/* Accent glow hover */
.card-hover-glow:hover {
    box-shadow: 0 8px 32px var(--accent-glow), var(--shadow-card);
    border-color: rgba(245, 133, 36, 0.2);
}

/* ==========================================================================
   STAGGERED ANIMATIONS
   Add .stagger class to parent, children animate with delay
   ========================================================================== */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stagger container */
.stagger > * {
    opacity: 0;
    animation: fadeSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }
.stagger > *:nth-child(7) { animation-delay: 300ms; }
.stagger > *:nth-child(8) { animation-delay: 350ms; }
.stagger > *:nth-child(9) { animation-delay: 400ms; }
.stagger > *:nth-child(10) { animation-delay: 450ms; }
.stagger > *:nth-child(11) { animation-delay: 500ms; }
.stagger > *:nth-child(12) { animation-delay: 550ms; }

/* Faster stagger variant */
.stagger-fast > * {
    opacity: 0;
    animation: fadeSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-fast > *:nth-child(1) { animation-delay: 0ms; }
.stagger-fast > *:nth-child(2) { animation-delay: 30ms; }
.stagger-fast > *:nth-child(3) { animation-delay: 60ms; }
.stagger-fast > *:nth-child(4) { animation-delay: 90ms; }
.stagger-fast > *:nth-child(5) { animation-delay: 120ms; }
.stagger-fast > *:nth-child(6) { animation-delay: 150ms; }
.stagger-fast > *:nth-child(7) { animation-delay: 180ms; }
.stagger-fast > *:nth-child(8) { animation-delay: 210ms; }

/* Scale-in stagger for grids */
.stagger-scale > * {
    opacity: 0;
    animation: scaleIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-scale > *:nth-child(1) { animation-delay: 0ms; }
.stagger-scale > *:nth-child(2) { animation-delay: 40ms; }
.stagger-scale > *:nth-child(3) { animation-delay: 80ms; }
.stagger-scale > *:nth-child(4) { animation-delay: 120ms; }
.stagger-scale > *:nth-child(5) { animation-delay: 160ms; }
.stagger-scale > *:nth-child(6) { animation-delay: 200ms; }
.stagger-scale > *:nth-child(7) { animation-delay: 240ms; }
.stagger-scale > *:nth-child(8) { animation-delay: 280ms; }

/* ==========================================================================
   KPI VALUE ANIMATION (Count-Up Effect)
   Apply .animate-value class, JS will handle the counting
   ========================================================================== */
.animate-value {
    display: inline-block;
    transition: transform 0.3s ease;
}

.animate-value.counting {
    animation: countPulse 0.1s ease infinite;
}

@keyframes countPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Value highlight on change */
.value-changed {
    animation: valueFlash 0.6s ease;
}

@keyframes valueFlash {
    0% { color: var(--text-primary); }
    30% { color: var(--accent); transform: scale(1.05); }
    100% { color: var(--text-primary); transform: scale(1); }
}

/* ==========================================================================
   PULSE ANIMATION FOR NEW ITEMS
   ========================================================================== */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: var(--shadow-card);
    }
    50% {
        box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-card);
    }
}

.pulse-new {
    animation: pulseGlow 2s ease-in-out 3;
}

/* Subtle pulse for attention */
@keyframes subtlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pulse-attention {
    animation: subtlePulse 1.5s ease-in-out infinite;
}

/* ==========================================================================
   BUTTON ENHANCEMENTS
   ========================================================================== */
.btn {
    position: relative;
    overflow: hidden;
}

/* Shimmer effect on hover for CTA buttons */
.btn.cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn.cta:hover::before {
    left: 100%;
}

/* Press effect */
.btn:active {
    transform: translateY(0) scale(0.98);
    transition: transform 0.1s ease;
}

/* ==========================================================================
   INPUT FOCUS ENHANCEMENTS
   ========================================================================== */
.input {
    transition: all 0.2s ease, box-shadow 0.2s ease;
}

.input:focus {
    transform: translateY(-1px);
}

/* ==========================================================================
   STATUS INDICATOR ENHANCEMENTS
   ========================================================================== */
.status-dot.active {
    position: relative;
}

.status-dot.active::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: var(--success);
    opacity: 0.3;
    animation: statusPing 1.5s ease-in-out infinite;
}

@keyframes statusPing {
    0%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ==========================================================================
   PAGE TRANSITION
   ========================================================================== */
.page-enter {
    animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   REDUCED MOTION SUPPORT
   Respect user preference for reduced animations
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .stagger > *,
    .stagger-fast > *,
    .stagger-scale > * {
        opacity: 1;
        animation: none;
    }

    .card-hover:hover,
    .card-hover-subtle:hover {
        transform: none;
    }
}
