﻿/* ============================================
   MAIN LAYOUT STYLES
   Extracted from MainLayout.razor for browser caching
   ============================================ */

/* ============================================
   BODY & LAYOUT SCROLL CONTROL
   ============================================ */

html, body {
    height: 100vh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.mud-layout {
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.mud-main-content {
    height: calc(100vh - 64px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 1.5rem;
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT WRAPPER - BALANCED SPACING
   ═══════════════════════════════════════════════════════════════ */

.main-content-wrapper {
    min-height: calc(100vh - 64px - 3rem);
    padding-top: 1.5rem !important;
    margin-bottom: 2rem !important;
}

@media (min-width: 1200px) {
    .main-content-wrapper {
        padding-top: 0.1rem !important;
    }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .main-content-wrapper {
        padding-top: 1.1rem !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .main-content-wrapper {
        padding-top: 1.5rem !important;
    }
}

@media (min-width: 361px) and (max-width: 480px) {
    .main-content-wrapper {
        padding-top: 1.25rem !important;
    }
}

@media (max-width: 360px) {
    .main-content-wrapper {
        padding-top: 1rem !important;
    }
}

.main-content-wrapper > * {
    margin-bottom: 1.5rem;
}

.main-content-wrapper > *:last-child {
    margin-bottom: 3rem;
}

/* MudDrawer */
.mud-drawer {
    height: 100vh !important;
    overflow: hidden !important;
    border-right: none;
    box-shadow: 4px 0 20px rgba(0,0,0,0.08);
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mud-drawer-paper {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    height: 100vh !important;
    overflow: hidden !important;
}

/* Cursor pointer for Radzen DataGrid cells */
.rz-selectable tbody tr.rz-data-row td,
.rz-selectable tbody tr.rz-data-row .rz-cell-data {
    cursor: pointer;
}

/* ============================================
   MODERN LAYOUT STYLES
   ============================================ */

.appbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ══════════════════════════════════════════════════════════════
   PROFESSIONAL HEADER DESIGN - DESKTOP & MOBILE
   ══════════════════════════════════════════════════════════════ */

.main-header.mud-appbar {
    background: #1a1a2e !important;
    height: 60px !important;
    padding: 0 24px !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15) !important;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    z-index: 1199 !important;
}

.main-header .mud-toolbar-content {
    gap: 16px;
    justify-content: space-between;
}

.header-menu-btn.mud-icon-button {
    color: rgba(255,255,255,0.9) !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,0.08) !important;
    transition: all 0.2s ease !important;
}

.header-menu-btn.mud-icon-button:hover {
    background: rgba(255,255,255,0.15) !important;
    transform: scale(1.05);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.header-brand:hover {
    background: rgba(255,255,255,0.05);
}

.header-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.header-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.header-brand-name {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-brand-tag {
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
    font-weight: 500;
}

/* STATUS BADGE */
.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    cursor: default;
    transition: all 0.3s ease;
    margin-inline-end: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

.header-status:hover {
    background: rgba(255,255,255,0.12);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.header-status.online {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.25)) !important;
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.header-status.online:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.3)) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.header-status.slow {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.25)) !important;
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.header-status.slow:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.3)) !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.header-status.offline {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.25)) !important;
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.header-status.offline:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(220, 38, 38, 0.3)) !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.header-status .network-icon {
    color: rgba(255, 255, 255, 0.95) !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.header-status-label {
    color: rgba(255,255,255,0.95);
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ACTION BUTTONS */
.header-action {
    position: relative;
    margin-inline-start: 4px;
}

.header-action .mud-icon-button {
    color: rgba(255,255,255,0.8) !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,0.08) !important;
    transition: all 0.2s ease !important;
}

.header-action .mud-icon-button:hover {
    color: white !important;
    background: rgba(255,255,255,0.15) !important;
}

/* USER PROFILE */
.header-user {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border-radius: 24px;
    background: rgba(255,255,255,0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-inline-start: 8px;
}

.header-user:hover {
    background: rgba(255,255,255,0.15);
}

.header-user-avatar.mud-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    width: 36px !important;
    height: 36px !important;
}

.header-user-arrow {
    color: rgba(255,255,255,0.6);
    transition: transform 0.2s ease;
}

.header-user:hover .header-user-arrow {
    transform: rotate(180deg);
}

/* ═══════════════════════════════════════════
   USER DROPDOWN - Discord/Twitter Style
   ═══════════════════════════════════════════ */

.user-dropdown.mud-popover-paper {
    background: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border: 1px solid #e4e6eb !important;
    padding: 0 !important;
    overflow: hidden !important;
    min-width: 220px !important;
}

.ud-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.ud-avatar {
    width: 40px !important;
    height: 40px !important;
    background: #e4e6eb !important;
    color: #65676b !important;
}

.ud-info {
    display: flex;
    flex-direction: column;
}

.ud-name {
    font-size: 15px;
    font-weight: 600;
    color: #050505;
}

.ud-email {
    font-size: 13px;
    color: #65676b;
}

.ud-divider {
    height: 1px;
    background: #e4e6eb;
    margin: 0;
}

.ud-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: #050505;
    font-size: 15px;
    font-weight: 500;
}

.ud-item:hover {
    background: #f2f2f2;
}

.ud-item .mud-icon-root {
    color: #65676b;
    font-size: 20px !important;
}

.ud-logout {
    color: #fa383e !important;
}

.ud-logout .mud-icon-root {
    color: #fa383e !important;
}

.ud-logout:hover {
    background: #ffebe9 !important;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE - HEADER
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .header-brand-text {
        display: none;
    }

    .header-status-label {
        display: none;
    }

    .header-status {
        padding: 8px;
        border-radius: 50%;
        width: 38px;
        height: 38px;
        justify-content: center;
        margin-inline-end: 4px;
    }

    .main-header .mud-toolbar-content {
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .main-header.mud-appbar {
        height: 56px !important;
        padding: 0 12px !important;
    }

    .main-header .mud-toolbar-content {
        gap: 8px;
    }

    .header-menu-btn.mud-icon-button {
        width: 40px !important;
        height: 40px !important;
        border-radius: 10px !important;
    }

    .header-brand-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .header-action .mud-icon-button {
        width: 38px !important;
        height: 38px !important;
        border-radius: 10px !important;
    }

    .header-action {
        margin-inline-start: 2px;
    }

    .header-action-desktop {
        display: none !important;
    }

    .header-status {
        width: 34px;
        height: 34px;
        margin-inline-end: 2px;
    }

    .header-user {
        padding: 3px;
        border-radius: 50%;
        margin-inline-start: 4px;
    }

    .header-user-arrow {
        display: none;
    }

    .header-user-avatar.mud-avatar {
        width: 32px !important;
        height: 32px !important;
    }
}

@media (max-width: 480px) {
    .main-header.mud-appbar {
        height: calc(52px + var(--safe-area-top)) !important;
        min-height: calc(52px + var(--safe-area-top)) !important;
        padding: var(--safe-area-top) 8px 0 8px !important;
    }

    .main-header .mud-toolbar {
        height: 52px !important;
        min-height: 52px !important;
    }

    .mud-main-content {
        height: calc(100% - 52px - var(--safe-area-top)) !important;
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + var(--safe-area-bottom));
    }

    .main-header .mud-toolbar-content {
        gap: 6px;
    }

    .header-menu-btn.mud-icon-button,
    .header-action .mud-icon-button {
        width: 34px !important;
        height: 34px !important;
    }

    .header-brand-icon {
        width: 32px;
        height: 32px;
    }

    .header-status {
        width: 30px;
        height: 30px;
    }

    .header-status-indicator {
        width: 6px;
        height: 6px;
    }

    .header-action {
        margin-inline-start: 1px;
    }

    .header-user {
        margin-inline-start: 2px;
    }

    .header-user-avatar.mud-avatar {
        width: 30px !important;
        height: 30px !important;
    }
}

@media (max-width: 360px) {
    .main-header.mud-appbar {
        height: calc(50px + var(--safe-area-top)) !important;
        min-height: calc(50px + var(--safe-area-top)) !important;
        padding: var(--safe-area-top) 6px 0 6px !important;
    }

    .main-header .mud-toolbar {
        height: 50px !important;
        min-height: 50px !important;
    }

    .mud-main-content {
        height: calc(100% - 50px - var(--safe-area-top)) !important;
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + var(--safe-area-bottom));
    }

    .main-header .mud-toolbar-content {
        gap: 4px;
    }

    .header-menu-btn.mud-icon-button,
    .header-action .mud-icon-button {
        width: 32px !important;
        height: 32px !important;
    }

    .header-brand-icon {
        width: 30px;
        height: 30px;
    }

    .header-status {
        width: 28px;
        height: 28px;
    }

    .header-user-avatar.mud-avatar {
        width: 28px !important;
        height: 28px !important;
    }
}

/* App Bar Enhancement */
.mud-appbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    height: 64px !important;
    flex-shrink: 0 !important;
}

.mud-appbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
}

.mud-appbar .mud-icon-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
}

.mud-appbar .mud-icon-button:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px) scale(1.05);
}

.mud-appbar .mud-icon-button:active {
    transform: translateY(0) scale(0.95);
}

.mud-appbar .mud-typography {
    font-weight: 800;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Main Content Background Pattern */
.mud-main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.03) 0%, transparent 50%), radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.mud-main-content > div {
    position: relative;
}

/* ============================================
   DIALOG FIXES
   ============================================ */

.mud-dialog-fullscreen {
    overflow-y: auto;
}

::deep .mud-dialog {
    direction: inherit;
}

.mud-dialog .mud-dialog-title {
    padding: 0 !important;
}

.mud-dialog .mud-dialog-content {
    padding: 0 !important;
}

::deep .mud-dialog .mud-dialog-content {
    margin-top: -22px !important;
    max-height: calc(100vh - 200px);
    max-height: calc(var(--app-height) - 200px);
    overflow-y: auto;
    direction: inherit;
    text-align: inherit;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    ::deep .mud-dialog .mud-dialog-content {
        max-height: calc(100vh - 150px);
        max-height: calc(var(--app-height) - 150px - var(--safe-area-top) - var(--safe-area-bottom));
        padding-bottom: calc(1.5rem + var(--safe-area-bottom));
    }

    .mud-dialog-container {
        padding-bottom: var(--safe-area-bottom);
    }
}

::deep .mud-dialog .mud-dialog-title {
    text-align: inherit;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, transparent 100%);
    padding: 1.5rem;
    font-weight: 700;
    border-bottom: 2px solid #e2e8f0;
    direction: inherit;
}

/* RTL specific dialog styles */
[dir="rtl"] ::deep .mud-dialog .mud-dialog-title {
    text-align: right;
}

[dir="rtl"] ::deep .mud-dialog .mud-dialog-content {
    text-align: right;
}

[dir="rtl"] ::deep .mud-dialog-actions {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* LTR specific dialog styles */
[dir="ltr"] ::deep .mud-dialog .mud-dialog-title {
    text-align: left;
}

[dir="ltr"] ::deep .mud-dialog .mud-dialog-content {
    text-align: left;
}

[dir="ltr"] ::deep .mud-dialog-actions {
    flex-direction: row;
    justify-content: flex-end;
}

::deep .mud-dialog-actions {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 1rem;
    align-items: center;
}

[dir="rtl"] ::deep .mud-dialog-actions .mud-button {
    margin-left: 0;
    margin-right: 0;
}

[dir="ltr"] ::deep .mud-dialog-actions .mud-button {
    margin-left: 0;
    margin-right: 0;
}

/* Close button positioning */
[dir="rtl"] ::deep .mud-dialog .mud-dialog-close-button {
    left: 0.5rem;
    right: auto;
    transition: left 0.3s ease, right 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[dir="ltr"] ::deep .mud-dialog .mud-dialog-close-button {
    right: 0.5rem;
    left: auto;
    transition: left 0.3s ease, right 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

::deep .mud-dialog .mud-dialog-close-button {
    position: absolute;
    top: 0.5rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

::deep .mud-dialog .mud-dialog-close-button:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

::deep .mud-dialog .mud-dialog-close-button:active {
    transform: scale(0.95) rotate(90deg);
}

::deep .mud-dialog .mud-dialog-close-button .mud-icon-root {
    color: #64748b;
    font-size: 1.25rem;
    transition: color 0.3s ease;
}

::deep .mud-dialog .mud-dialog-close-button:hover .mud-icon-root {
    color: #ef4444;
}

::deep .mud-dialog .mud-paper {
    position: relative;
    direction: inherit;
}

::deep .mud-dialog {
    direction: inherit !important;
    animation: dialogDirectionChange 0.3s ease;
}

::deep .mud-dialog-container {
    direction: inherit !important;
}

[dir="rtl"] ::deep .mud-dialog .mud-dialog-title {
    padding-left: 3rem;
    padding-right: 1.5rem;
    transition: padding 0.3s ease;
}

[dir="ltr"] ::deep .mud-dialog .mud-dialog-title {
    padding-right: 3rem;
    padding-left: 1.5rem;
    transition: padding 0.3s ease;
}

@keyframes dialogDirectionChange {
    0% { opacity: 0.8; }
    100% { opacity: 1; }
}

@media (max-width: 768px) {
    ::deep .mud-dialog .mud-dialog-close-button {
        width: 32px;
        height: 32px;
        top: 0.375rem;
    }

    [dir="rtl"] ::deep .mud-dialog .mud-dialog-close-button {
        left: 0.375rem;
        right: auto;
    }

    [dir="ltr"] ::deep .mud-dialog .mud-dialog-close-button {
        right: 0.375rem;
        left: auto;
    }

    [dir="rtl"] ::deep .mud-dialog .mud-dialog-title {
        padding-left: 2.75rem;
        padding-right: 1.25rem;
    }

    [dir="ltr"] ::deep .mud-dialog .mud-dialog-title {
        padding-right: 2.75rem;
        padding-left: 1.25rem;
    }
}

/* Form elements in dialogs */
[dir="rtl"] ::deep .mud-dialog .mud-input-control {
    text-align: right;
}

[dir="ltr"] ::deep .mud-dialog .mud-input-control {
    text-align: left;
}

[dir="rtl"] ::deep .mud-dialog .mud-input {
    text-align: right;
    direction: rtl;
}

[dir="ltr"] ::deep .mud-dialog .mud-input {
    text-align: left;
    direction: ltr;
}

[dir="rtl"] ::deep .mud-dialog .mud-dialog-content {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
}

[dir="ltr"] ::deep .mud-dialog .mud-dialog-content {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

[dir="rtl"] ::deep .mud-dialog .mud-input-label {
    text-align: right;
    right: 0;
    left: auto;
}

[dir="ltr"] ::deep .mud-dialog .mud-input-label {
    text-align: left;
    left: 0;
    right: auto;
}

[dir="rtl"] ::deep .mud-dialog .mud-select {
    text-align: right;
}

[dir="ltr"] ::deep .mud-dialog .mud-select {
    text-align: left;
}

[dir="rtl"] ::deep .mud-dialog .mud-checkbox,
[dir="rtl"] ::deep .mud-dialog .mud-radio {
    flex-direction: row-reverse;
}

[dir="rtl"] ::deep .mud-dialog .mud-checkbox .mud-checkbox-label,
[dir="rtl"] ::deep .mud-dialog .mud-radio .mud-radio-label {
    margin-right: 0.5rem;
    margin-left: 0;
}

[dir="ltr"] ::deep .mud-dialog .mud-checkbox .mud-checkbox-label,
[dir="ltr"] ::deep .mud-dialog .mud-radio .mud-radio-label {
    margin-left: 0.5rem;
    margin-right: 0;
}

::deep .mud-dialog-container {
    direction: inherit;
}

[dir="rtl"] ::deep .mud-dialog .mud-input-adornment-start {
    margin-right: 0;
    margin-left: 0.5rem;
}

[dir="rtl"] ::deep .mud-dialog .mud-input-adornment-end {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="ltr"] ::deep .mud-dialog .mud-input-adornment-start {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="ltr"] ::deep .mud-dialog .mud-input-adornment-end {
    margin-right: 0;
    margin-left: 0.5rem;
}

[dir="rtl"] ::deep .mud-dialog .mud-dialog-title {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
}

[dir="rtl"] ::deep .mud-dialog .validation-message {
    text-align: right;
}

[dir="ltr"] ::deep .mud-dialog .validation-message {
    text-align: left;
}

[dir="rtl"] ::deep .mud-dialog .mud-alert {
    text-align: right;
}

[dir="ltr"] ::deep .mud-dialog .mud-alert {
    text-align: left;
}

[dir="rtl"] ::deep .mud-dialog .mud-input-helper-text {
    text-align: right;
}

[dir="ltr"] ::deep .mud-dialog .mud-input-helper-text {
    text-align: left;
}

[dir="rtl"] ::deep .mud-dialog .mud-switch {
    flex-direction: row-reverse;
}

[dir="rtl"] ::deep .mud-dialog .mud-switch .mud-switch-label {
    margin-right: 0.5rem;
    margin-left: 0;
}

[dir="ltr"] ::deep .mud-dialog .mud-switch .mud-switch-label {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* ============================================
   RADZEN COMPONENT FIXES
   ============================================ */

.rz-datepicker,
.rz-dropdown-panel {
    z-index: 2000 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-radius: 12px;
}

@media (max-width: 768px) {
    .rz-datepicker,
    .rz-dropdown-panel {
        position: fixed !important;
        max-width: calc(100vw - 32px) !important;
        max-height: calc(var(--app-height) - 100px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .rz-datepicker .rz-popup {
        left: 16px !important;
        right: 16px !important;
        max-width: calc(100vw - 32px) !important;
    }
}

.rz-datepicker-calendar td .rz-state-default {
    font-size: 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.rz-datepicker-calendar td .rz-state-default:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.05);
}

/* ============================================
   SYNCFUSION GRID
   ============================================ */

.e-grid .e-toolbar {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%) !important;
    border-bottom: 2px solid #e9ecef;
    padding: 0px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.e-grid .e-headercell,
.e-grid .e-rowcell {
    white-space: normal;
    word-break: break-word;
}

.e-grid .e-headercell .e-text-overflow,
.e-grid .e-rowcell .e-text-overflow {
    white-space: normal;
    word-break: break-word;
}

.e-grid .e-headercell {
    background: #f7fafc;
    color: #1a202c;
    font-weight: 600;
    border-bottom: 2px solid #cbd5e0;
}

/* Syncfusion Excel Filter Fix */
.e-dialog.e-filter-popup,
.e-dialog.e-excelfilter {
    z-index: 999999 !important;
}

.e-popup.e-popup-open.e-dialog.e-filter-popup {
    z-index: 999999 !important;
}

.e-dialog.ff-fixed {
    position: fixed !important;
    z-index: 999999 !important;
    margin: 0 !important;
    height: auto !important;
}

.e-dialog.ff-fixed > .e-dlg-content {
    height: auto !important;
}

/* Sweet Alert Z-Index — must sit above BlazorSpinner overlay (z-index ~999999) */
.swal2-container {
    z-index: 2000000 !important;
}

/* Session-expired dialog — highest layer, above all spinners and overlays */
.swal2-container.blurred-backdrop {
    z-index: 2000001 !important;
    background: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(4px) !important;
}

/* When SweetAlert is visible, disable spinner overlay pointer events */
body.swal2-shown .spinner-container,
body.swal2-shown [class*="spinner"] {
    pointer-events: none !important;
    z-index: 0 !important;
}

::deep .swal2-popup {
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ============================================
   MOBILE RESPONSIVE - MAIN LAYOUT
   ============================================ */

@media (max-width: 768px) {
    :root {
        --header-height: var(--mobile-header-height);
    }

    html, body {
        height: 100%;
        height: var(--app-height);
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }

    .mud-layout {
        height: 100%;
        height: var(--app-height);
        min-height: 100vh;
        min-height: -webkit-fill-available;
        width: 100vw !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
    }

    .mud-main-content {
        height: calc(100% - var(--mobile-header-height)) !important;
        min-height: calc(100vh - var(--mobile-header-height));
        min-height: calc(var(--app-height) - var(--mobile-header-height));
        padding: 0.5rem 1rem 1rem 1rem;
        padding-bottom: calc(1rem + var(--safe-area-bottom) + 2rem);
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .main-content-wrapper {
        min-height: calc(var(--app-height) - var(--mobile-header-height) - 2rem);
        padding-top: 1.5rem !important;
        padding-bottom: 4rem !important;
        margin-bottom: 3rem !important;
    }

    .main-content-wrapper > * {
        margin-bottom: 1.25rem;
    }

    .main-content-wrapper > *:last-child {
        margin-bottom: 4rem;
    }

    .mud-appbar {
        height: 56px !important;
        padding: 0 0.5rem !important;
    }

    .mud-appbar .mud-toolbar {
        padding: 0 0.25rem !important;
        gap: 0.25rem;
    }

    .mud-appbar .app-title {
        display: none;
    }

    .mud-appbar .mud-typography {
        font-size: 0.9rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mud-appbar .mud-icon-button {
        padding: 6px !important;
        margin: 0 1px !important;
    }

    .mud-appbar .mud-icon-button .mud-icon-root {
        font-size: 1.25rem !important;
    }

    .rz-datepicker .rz-popup {
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        max-width: 100%;
        max-width: calc(100vw - 16px) !important;
        margin: 0 8px !important;
    }

    .mud-dialog {
        overflow-y: visible !important;
        max-height: unset;
        margin: 0;
        max-height: calc(var(--app-height) - 32px) !important;
        margin: 16px !important;
    }

    .mud-dialog-container {
        overflow: auto;
        padding: 0.5rem;
        padding-bottom: calc(0.5rem + var(--safe-area-bottom));
        max-height: var(--app-height);
        -webkit-overflow-scrolling: touch;
    }

    .mud-dialog-container.mud-dialog-center {
        align-items: flex-start;
        padding-top: calc(1rem + var(--safe-area-top));
    }

    ::deep .mud-dialog .mud-dialog-content {
        max-height: calc(100vh - 150px);
        max-height: calc(var(--app-height) - 150px);
        padding-bottom: calc(1rem + var(--safe-area-bottom));
    }

    input:focus,
    textarea:focus,
    select:focus {
        scroll-margin-bottom: 200px;
    }
}

@media (max-width: 480px) {
    .mud-appbar {
        padding: 0 0.25rem !important;
        padding-top: var(--safe-area-top) !important;
    }

    .mud-appbar .mud-toolbar {
        gap: 0.125rem;
    }

    .mud-appbar .mud-typography.app-title-text {
        display: none !important;
    }

    .mud-appbar .mud-icon-button {
        padding: 4px !important;
        margin: 0 !important;
        min-width: 36px !important;
        width: 36px !important;
        height: 36px !important;
    }

    .mud-appbar .mud-icon-button .mud-icon-root {
        font-size: 1.1rem !important;
    }

    .mud-main-content {
        padding: 0.5rem 0.75rem 0.75rem 0.75rem !important;
        padding-bottom: calc(0.75rem + var(--safe-area-bottom) + 20px) !important;
    }

    .main-content-wrapper {
        padding-top: 2.5rem !important;
        padding-bottom: 4rem !important;
        margin-bottom: 3rem !important;
    }

    .mud-dialog {
        max-height: calc(var(--app-height) - 16px) !important;
        margin: 8px !important;
    }
}

@media (max-width: 360px) {
    .main-content-wrapper {
        padding-top: 2.25rem !important;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .mud-appbar .mud-typography.app-title-text {
        display: inline-flex !important;
        font-size: 0.875rem !important;
        max-width: 150px;
    }
}

@media (max-width: 768px) {
    .appbar-actions {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .appbar-actions {
        gap: 0.125rem;
    }

    .appbar-actions .mud-icon-button {
        padding: 4px !important;
        min-width: 32px !important;
        width: 32px !important;
        height: 32px !important;
    }
}

/* Tablet and Desktop */
@media (min-width: 769px) {
    html, body {
        height: 100%;
        height: var(--app-height);
        min-height: 100vh;
        overflow: hidden !important;
    }

    .mud-layout {
        height: 100%;
        height: var(--app-height);
        min-height: 100vh;
        overflow: hidden !important;
    }

    .mud-main-content {
        height: calc(100% - var(--header-height)) !important;
        min-height: calc(100vh - var(--header-height));
        min-height: calc(var(--app-height) - var(--header-height));
        padding-bottom: calc(1.5rem + var(--safe-area-bottom));
    }
}

/* ═══════════════════════════════════════════════════════════════
   TALL SCREENS FIX (20:9, 21:9 Aspect Ratios)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) and (min-aspect-ratio: 19/9) {
    .mud-main-content {
        padding-bottom: calc(1rem + var(--safe-area-bottom) + 3rem) !important;
    }

    .main-content-wrapper {
        padding-bottom: 5rem !important;
        margin-bottom: 4rem !important;
    }

    .main-content-wrapper > *:last-child {
        margin-bottom: 5rem !important;
    }
}

@media (max-width: 768px) and (min-aspect-ratio: 20/9) {
    .mud-main-content {
        padding-bottom: calc(1rem + var(--safe-area-bottom) + 4rem) !important;
    }

    .main-content-wrapper {
        padding-bottom: 6rem !important;
        margin-bottom: 5rem !important;
    }

    .main-content-wrapper > *:last-child {
        margin-bottom: 6rem !important;
    }
}

/* GESTURE BAR DEVICES */
.has-gesture-bar.tall-screen .mud-main-content {
    padding-bottom: calc(1rem + var(--safe-area-bottom) + 5rem) !important;
}

.has-gesture-bar.tall-screen .main-content-wrapper {
    padding-bottom: 7rem !important;
    margin-bottom: 6rem !important;
}

.has-gesture-bar.tall-screen .main-content-wrapper > *:last-child {
    margin-bottom: 7rem !important;
}

@media (max-width: 768px) {
    .mud-main-content[data-device*="OnePlus"],
    .mud-main-content[data-device*="oneplus"] {
        padding-bottom: calc(1rem + var(--safe-area-bottom) + 5rem) !important;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
    border-radius: 10px;
    border: 2px solid #f1f1f1;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
}

/* Page Transitions */
.page-transition-enter {
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Drawer Toggle Animation */
.mud-drawer-open {
    animation: drawerSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes drawerSlide {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

[dir="rtl"] .mud-drawer-open {
    animation: drawerSlideRtl 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes drawerSlideRtl {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

::deep .blazored-toast-container {
    z-index: 100000 !important;
    position: fixed !important;
    padding-bottom: var(--safe-area-bottom) !important;
}

::deep .blazored-toast {
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    margin-bottom: 1rem;
    animation: slideInToast 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

::deep .blazored-toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-left: 4px solid #047857;
}

::deep .blazored-toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-left: 4px solid #b91c1c;
}

::deep .blazored-toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-left: 4px solid #1d4ed8;
}

::deep .blazored-toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-left: 4px solid #b45309;
}

@keyframes slideInToast {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

[dir="rtl"] ::deep .blazored-toast {
    animation: slideInToastRTL 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[dir="rtl"] ::deep .blazored-toast-success,
[dir="rtl"] ::deep .blazored-toast-error,
[dir="rtl"] ::deep .blazored-toast-info,
[dir="rtl"] ::deep .blazored-toast-warning {
    border-left: none;
    border-right: 4px solid;
}

@keyframes slideInToastRTL {
    from { opacity: 0; transform: translateX(-100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Focus States */
.mud-icon-button:focus-visible {
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 2px;
}

/* ============================================
   PREVENT UNWANTED TEXT SELECTION & TAP HIGHLIGHT
   Body-level disable, re-enable for content areas
   ============================================ */

/*body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}*/

/* Re-enable selection for actual text content and inputs */
/*input,
textarea,
select,
[contenteditable="true"],
pre,
code,
.mud-input input,
.mud-input textarea,
.mud-input-slot,
.mud-table-cell,
.mud-typography:not(.mud-appbar .mud-typography),
.rz-cell-data,
.mud-alert-message,
h1, h2, h3, h4, h5, h6,
p,
span.selectable,
.selectable {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
*/
/* Ensure all icon elements never show ligature/title text on selection */
.mud-icon-root,
.mud-svg-icon,
svg,
i[class*="fa-"],
i.fas,
i.far,
i.fab,
i.fal,
i.fad,
.mud-icon-button .mud-icon-root,
.mud-button-icon-start,
.mud-button-icon-end,
[class*="mdi-"],
.material-icons {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events: none;
}

/* Restore pointer-events on clickable icon containers */
.mud-icon-button,
.mud-button-root,
.mud-fab,
button,
a {
    pointer-events: auto;
}

/* Print Styles */
@media print {
    .mud-appbar,
    .mud-drawer,
    .offline-overlay {
        display: none !important;
    }

    .mud-main-content {
        background: white;
        padding: 0;
    }
}

/* ============================================
   NETWORK SPEED INDICATOR STYLES
   ============================================ */

.speed-network-server {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    margin: 0 0.5rem;
}

.speed-network-server:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.network-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse-network 2s ease-in-out infinite;
    box-shadow: 0 0 10px currentColor;
}

.network-good {
    background-color: #10b981;
    color: #10b981;
}

.network-medium {
    background-color: #f59e0b;
    color: #f59e0b;
}

.network-poor {
    background-color: #ef4444;
    color: #ef4444;
}

.network-text {
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.network-ping {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 500;
}

@keyframes pulse-network {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.network-icon {
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.network-good .network-icon {
    color: #10b981;
    animation: wifi-pulse 2s ease-in-out infinite;
}

.network-medium .network-icon {
    color: #f59e0b;
    animation: wifi-warning 1.5s ease-in-out infinite;
}

.network-poor .network-icon {
    color: #ef4444;
    animation: wifi-error 1s ease-in-out infinite;
}

@keyframes wifi-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes wifi-warning {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(-2deg); }
    75% { transform: scale(1.05) rotate(2deg); }
}

@keyframes wifi-error {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.9); opacity: 0.6; }
}

@keyframes rotate-icon {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.network-checking .network-icon {
    animation: rotate-icon 1s linear infinite;
    color: #3b82f6;
}

@media (max-width: 992px) {
    .speed-network-server {
        padding: 0.375rem 0.625rem;
        margin: 0 0.25rem;
        gap: 0.375rem;
        border-radius: 16px;
    }

    .network-indicator {
        width: 10px;
        height: 10px;
    }

    .network-text {
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    .network-icon {
        font-size: 0.875rem;
    }

    .network-ping {
        display: none;
    }

    .network-good .network-icon {
        animation: wifi-pulse-mobile 1.5s ease-in-out infinite;
    }

    .network-medium .network-icon {
        animation: wifi-warning-mobile 1.2s ease-in-out infinite;
    }

    .network-poor .network-icon {
        animation: wifi-error-mobile 1s ease-in-out infinite;
    }
}

@keyframes wifi-pulse-mobile {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes wifi-warning-mobile {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(-3deg); }
}

@keyframes wifi-error-mobile {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.85); opacity: 0.5; }
}

@media (max-width: 576px) {
    .speed-network-server {
        padding: 0.25rem 0.5rem;
        margin: 0 0.125rem;
        gap: 0.25rem;
        border-radius: 12px;
    }

    .network-indicator {
        width: 8px;
        height: 8px;
    }

    .network-text {
        font-size: 0.625rem;
    }

    .network-text span {
        display: none;
    }

    .network-icon {
        font-size: 0.75rem;
        margin: 0;
    }

    .speed-network-server:hover {
        transform: none;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .speed-network-server {
        padding: 0.4rem 0.75rem;
    }

    .network-text {
        font-size: 0.8125rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   MUDTABLE MOBILE OPTIMIZATION - FOOTER & PAGINATION
   ═══════════════════════════════════════════════════════════════ */

::deep .mud-table {
    width: 100%;
    overflow-x: auto;
}

@media (max-width: 768px) {
    ::deep .mud-table-pagination {
        padding: 0.5rem 0.25rem !important;
        gap: 0.25rem !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        min-height: auto !important;
    }

    ::deep .mud-table-pagination .mud-toolbar-content {
        padding: 0.25rem !important;
        gap: 0.25rem !important;
        flex-wrap: wrap !important;
    }

    ::deep .mud-table-pagination .mud-icon-button,
    ::deep .mud-table-pagination .mud-button-root {
        width: 32px !important;
        height: 32px !important;
        padding: 4px !important;
        min-width: 32px !important;
        margin: 0 2px !important;
    }

    ::deep .mud-table-pagination .mud-icon-button .mud-icon-root {
        font-size: 1.125rem !important;
    }

    ::deep .mud-table-pagination .mud-icon-button:first-child,
    ::deep .mud-table-pagination .mud-icon-button:last-child {
        display: none !important;
    }

    ::deep .mud-table-pagination .mud-typography,
    ::deep .mud-table-pagination-caption {
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        padding: 0 0.25rem !important;
        margin: 0 !important;
    }

    ::deep .mud-table-pagination .mud-input,
    ::deep .mud-table-pagination .mud-select {
        font-size: 0.75rem !important;
        padding: 0.25rem !important;
        min-width: 50px !important;
        width: 60px !important;
        margin: 0 0.25rem !important;
    }

    ::deep .mud-table-pagination .mud-input-control {
        margin: 0 !important;
    }

    ::deep .mud-table-pagination .mud-input-slot {
        padding: 0.25rem 0.5rem !important;
    }

    ::deep .mud-table-pagination-caption {
        order: -1 !important;
        width: 100% !important;
        text-align: center !important;
        margin-bottom: 0.25rem !important;
    }

    ::deep .mud-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    ::deep .mud-table .mud-table-cell {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.875rem !important;
    }

    ::deep .mud-table .mud-table-head .mud-table-cell {
        padding: 0.625rem 0.25rem !important;
        font-size: 0.8125rem !important;
        font-weight: 600 !important;
    }

    ::deep .mud-table-toolbar {
        padding: 0.5rem !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    ::deep .mud-table-toolbar .mud-input {
        font-size: 0.875rem !important;
    }
}

@media (max-width: 480px) {
    ::deep .mud-table-pagination {
        padding: 0.375rem 0.125rem !important;
    }

    ::deep .mud-table-pagination .mud-icon-button,
    ::deep .mud-table-pagination .mud-button-root {
        width: 28px !important;
        height: 28px !important;
        padding: 2px !important;
        min-width: 28px !important;
        margin: 0 1px !important;
    }

    ::deep .mud-table-pagination .mud-icon-button .mud-icon-root {
        font-size: 1rem !important;
    }

    ::deep .mud-table-pagination .mud-typography,
    ::deep .mud-table-pagination-caption {
        font-size: 0.6875rem !important;
    }

    ::deep .mud-table-pagination .mud-input,
    ::deep .mud-table-pagination .mud-select {
        font-size: 0.6875rem !important;
        min-width: 45px !important;
        width: 50px !important;
    }

    ::deep .mud-table-pagination .mud-input-label,
    ::deep .mud-table-pagination-info-text {
        display: none !important;
    }

    ::deep .mud-table .mud-table-cell {
        padding: 0.375rem 0.125rem !important;
        font-size: 0.8125rem !important;
    }
}

@media (max-width: 360px) {
    ::deep .mud-table-pagination,
    ::deep .mud-table-pagination .mud-toolbar-content {
        flex-direction: column !important;
        align-items: center !important;
    }

    ::deep .mud-table-pagination .mud-icon-button,
    ::deep .mud-table-pagination .mud-button-root {
        width: 26px !important;
        height: 26px !important;
    }

    ::deep .mud-table-pagination .mud-typography {
        font-size: 0.625rem !important;
    }

    ::deep .mud-table-pagination .mud-pagination-item {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLL TO TOP BUTTON
   ═══════════════════════════════════════════════════════════════ */

.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
}

.scroll-to-top:active {
    transform: translateY(-2px);
}

[dir="rtl"] .scroll-to-top {
    right: auto;
    left: 2rem;
}

@media (max-width: 768px) {
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: calc(1.5rem + var(--safe-area-bottom));
        right: 1.5rem;
    }

    [dir="rtl"] .scroll-to-top {
        right: auto;
        left: 1.5rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   LOADING MODAL (CENTERED)
   ═══════════════════════════════════════════════════════════════ */

.loading-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-modal.visible {
    opacity: 1;
    visibility: visible;
}

.loading-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}

.loading-modal-content {
    position: relative;
    background: white;
    padding: 3rem 4rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.loading-modal.visible .loading-modal-content {
    transform: scale(1);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a2e;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   OFFLINE MODAL (CENTERED)
   ═══════════════════════════════════════════════════════════════ */

.offline-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.offline-modal.visible {
    opacity: 1;
    visibility: visible;
}

.offline-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.offline-modal-content {
    position: relative;
    background: white;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: calc(100% - 2rem);
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.offline-modal.visible .offline-modal-content {
    transform: scale(1);
}

.offline-icon-wrapper {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.offline-icon {
    font-size: 2rem;
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.offline-title {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

.offline-message {
    margin: 0 0 2rem;
    font-size: 1rem;
    color: #64748b;
    line-height: 1.6;
}

.offline-retry-btn {
    width: 100%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.offline-retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.offline-retry-btn:active {
    transform: translateY(0);
}

.offline-retry-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.offline-ping-info {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-bottom: 1.5rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.offline-retry-btn .fa-spin {
    animation: spin 1s linear infinite;
}

@media (max-width: 768px) {
    .offline-modal-content {
        padding: 2rem;
    }

    .offline-icon-wrapper {
        width: 70px;
        height: 70px;
    }

    .offline-icon {
        font-size: 1.75rem;
    }

    .offline-title {
        font-size: 1.25rem;
    }

    .offline-message {
        font-size: 0.9375rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   KEYBOARD SHORTCUTS OVERLAY
   ═══════════════════════════════════════════════════════════════ */

.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.shortcuts-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.shortcuts-panel {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 600px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.shortcuts-overlay.visible .shortcuts-panel {
    transform: scale(1);
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.shortcuts-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

.shortcuts-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.shortcuts-close:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

.shortcuts-list {
    display: grid;
    gap: 1rem;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
}

.shortcut-desc {
    font-size: 0.9375rem;
    color: #64748b;
}

.shortcut-keys {
    display: flex;
    gap: 0.5rem;
}

.shortcut-key {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a1a2e;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* PAGE TRANSITIONS */
.page-loading {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.page-loading.visible {
    opacity: 1;
    visibility: visible;
}

.page-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.page-loading-text {
    margin-top: 1rem;
    font-size: 0.9375rem;
    color: #64748b;
    font-weight: 600;
}

/* PERFORMANCE HINTS */
.performance-hint {
    will-change: transform, opacity;
    contain: layout style paint;
}

.lazy-load {
    content-visibility: auto;
}

/* MICRO-INTERACTIONS */
.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple-effect:active::after {
    width: 300px;
    height: 300px;
}

@media (max-width: 768px) {
    .shortcuts-panel {
        padding: 1.5rem;
    }

    .shortcuts-title {
        font-size: 1.25rem;
    }

    .shortcut-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
