/* ============================================
   SupportDesk — Global Styles
   Design Token System
   ============================================ */

/* ─── CSS Design Tokens (Light Mode) ─── */
:root {
    /* Backgrounds */
    --color-bg:             #F5F6FA;
    --color-bg-elevated:    #FFFFFF;
    --color-bg-card:        #FFFFFF;
    --color-bg-hover:       #F9FAFB;
    --color-bg-input:       #FFFFFF;
    --color-sidebar:        #1A2332;

    /* Borders */
    --color-border:         #E8EAED;
    --color-border-subtle:  #F3F4F6;

    /* Text */
    --color-heading:        #1A2332;
    --color-text:           #374151;
    --color-text-secondary: #6B7280;
    --color-text-muted:     #9CA3AF;

    /* Brand / Primary */
    --color-primary:        #5C6BC0;
    --color-primary-hover:  #7C83FD;
    --color-primary-subtle: rgba(92, 107, 192, 0.10);
    --color-primary-light:  #A5B4FC;

    /* Status colours */
    --color-success:        #10B981;
    --color-success-subtle: rgba(16, 185, 129, 0.10);
    --color-warning:        #F59E0B;
    --color-warning-subtle: rgba(245, 158, 11, 0.10);
    --color-danger:         #EF4444;
    --color-danger-subtle:  rgba(239, 68, 68, 0.10);
    --color-purple:         #8B5CF6;
    --color-purple-subtle:  rgba(139, 92, 246, 0.10);
    --color-info:           #3B82F6;

    /* Gradients */
    --gradient-primary:     linear-gradient(135deg, #5C6BC0, #7C83FD);
    --gradient-hero:        linear-gradient(135deg, #5C6BC0 0%, #8B5CF6 50%, #7C83FD 100%);

    /* Shadows — indigo-tinted for light mode polish */
    --shadow-sm:   0 2px 8px rgba(92, 107, 192, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md:   0 4px 20px rgba(92, 107, 192, 0.10), 0 2px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg:   0 8px 40px rgba(92, 107, 192, 0.14), 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 8px 40px rgba(92, 107, 192, 0.28), 0 2px 8px rgba(0, 0, 0, 0.06);

    /* Border radius */
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --radius-xl:   20px;
    --radius-pill: 999px;

    /* Layout */
    --topbar-height: 64px;
    --transition:    0.2s ease;

    /* Font */
    --font-family: 'Inter', 'Roboto', 'Helvetica Neue', sans-serif;
}

/* ─── Dark Mode Token Overrides ─── */
:root.app-dark {
    --color-bg:             #0F1923;
    --color-bg-elevated:    #1A2332;
    --color-bg-card:        #1E2D42;
    --color-bg-hover:       #243350;
    --color-bg-input:       #151E2D;

    --color-border:         #2D3E56;
    --color-border-subtle:  #1E2D42;

    --color-heading:        #E5E7EB;
    --color-text:           #D1D5DB;
    --color-text-secondary: #9CA3AF;
    --color-text-muted:     #6B7280;

    --color-primary-subtle: rgba(92, 107, 192, 0.15);
    --color-success-subtle: rgba(16, 185, 129, 0.15);
    --color-warning-subtle: rgba(245, 158, 11, 0.15);
    --color-danger-subtle:  rgba(239, 68, 68, 0.15);
    --color-purple-subtle:  rgba(139, 92, 246, 0.15);

    --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.40);
    --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.50);
    --shadow-glow: 0 0 30px rgba(92, 107, 192, 0.20);
}

/* ─── Base Reset ─── */
html, body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Light mode — subtle indigo-tinted gradient so cards visually float */
body {
    background: linear-gradient(160deg, #E8EEFF 0%, #EEF2FF 25%, #F5F6FA 60%, #F8F9FF 100%);
    min-height: 100vh;
}

/* Dark mode — flat deep navy */
:root.app-dark body {
    background: var(--color-bg);
}

/* ─── Glassmorphism TopBar ─── */
.mud-appbar {
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}

/* ─── Custom Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ─── Gradient Text Utility ─── */
.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   SIDEBAR NAV
   ============================================ */

/* Section labels above nav groups */
.nav-section-label {
    color: rgba(255, 255, 255, 0.28);
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 4px 8px 6px;
}

/* Sidebar brand icon (gradient square) */
.sidebar-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(92, 107, 192, 0.40);
}

.sidebar-brand-name {
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar-brand-version {
    color: rgba(255, 255, 255, 0.30);
    font-size: 0.68rem;
}

/* Sidebar bottom user strip */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer-name {
    color: white;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer-email {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* All nav links in the sidebar */
.sd-nav .mud-nav-link {
    color: rgba(255, 255, 255, 0.65) !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 2px !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    padding: 10px 12px !important;
    transition: background var(--transition), color var(--transition) !important;
}

.sd-nav .mud-nav-link .mud-nav-link-icon {
    color: rgba(255, 255, 255, 0.45) !important;
    font-size: 1.15rem !important;
}

.sd-nav .mud-nav-link:hover {
    background: rgba(255, 255, 255, 0.07) !important;
    color: rgba(255, 255, 255, 0.90) !important;
}

.sd-nav .mud-nav-link:hover .mud-nav-link-icon {
    color: rgba(255, 255, 255, 0.80) !important;
}

.sd-nav .mud-nav-link.active,
.sd-nav .mud-nav-link[aria-current="page"] {
    background: rgba(92, 107, 192, 0.25) !important;
    color: var(--color-primary-light) !important;
}

.sd-nav .mud-nav-link.active .mud-nav-link-icon,
.sd-nav .mud-nav-link[aria-current="page"] .mud-nav-link-icon {
    color: var(--color-primary-light) !important;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-weight: 800 !important;
    color: var(--color-heading) !important;
    letter-spacing: -0.4px !important;
    margin-bottom: 4px !important;
    line-height: 1.2 !important;
}

.page-subtitle {
    color: var(--color-text-secondary) !important;
    font-size: 0.875rem !important;
}

/* ============================================
   STAT CARDS  (primary KPI cards)
   ============================================ */
.stat-card {
    border-radius: var(--radius-lg) !important;
    background: var(--color-bg-card) !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: var(--shadow-md) !important;
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-glow) !important;
    transform: translateY(-3px);
}

.stat-card-inner {
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Gradient numbers — the headline visual upgrade */
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -1px;
}

.stat-change { font-size: 0.75rem; font-weight: 500; }
.stat-change.positive { color: var(--color-success); }
.stat-change.negative { color: var(--color-warning); }

.stat-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Icon background helpers */
.icon-bg-primary { background: var(--color-primary-subtle); }
.icon-bg-warning { background: var(--color-warning-subtle); }
.icon-bg-purple  { background: var(--color-purple-subtle); }
.icon-bg-success { background: var(--color-success-subtle); }

/* ============================================
   MINI STAT  (secondary row cards)
   ============================================ */
.mini-stat {
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--color-border) !important;
    background: var(--color-bg-card) !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.mini-stat:hover {
    box-shadow: var(--shadow-glow) !important;
    transform: translateY(-3px);
}

.mini-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mini-stat-label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.mini-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-heading);
    line-height: 1.2;
}

.mini-stat-sub { font-size: 0.72rem; }

/* ============================================
   CONTENT CARDS
   ============================================ */
.content-card {
    border-radius: var(--radius-lg) !important;
    background: var(--color-bg-card) !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: var(--shadow-md) !important;
    overflow: hidden;
}

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

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--color-border) !important;
    background: var(--color-bg-card) !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* ============================================
   STATUS TABS
   ============================================ */
.status-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-pill {
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all var(--transition);
    user-select: none;
    display: inline-flex;
    align-items: center;
}

.tab-pill-count {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
}

/* ============================================
   TABLE
   ============================================ */
.table-header {
    color: var(--color-text-muted) !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.6px !important;
}

/* ============================================
   BADGES  — priority & status
   ============================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

/* Priority */
.badge-critical { background: #FEE2E2; color: #B91C1C; }
.badge-high     { background: #FEF3C7; color: #B45309; }
.badge-medium   { background: #EEF0FB; color: #3730A3; }
.badge-low      { background: #ECFDF5; color: #065F46; }

/* Status */
.badge-open        { background: #FEF3C7; color: #B45309; }
.badge-inprogress  { background: #EDE9FE; color: #6D28D9; }
.badge-resolved    { background: #ECFDF5; color: #065F46; }
.badge-closed      { background: #F3F4F6; color: #4B5563; }

/* Agent status */
.badge-active  { background: #ECFDF5; color: #065F46; }
.badge-away    { background: #FEF3C7; color: #B45309; }
.badge-offline { background: #F3F4F6; color: #4B5563; }

/* Dark mode badge overrides */
:root.app-dark .badge-critical   { background: rgba(239, 68, 68, 0.15);   color: #FCA5A5; }
:root.app-dark .badge-high       { background: rgba(245, 158, 11, 0.15);  color: #FCD34D; }
:root.app-dark .badge-medium     { background: var(--color-primary-subtle); color: var(--color-primary-light); }
:root.app-dark .badge-low        { background: rgba(16, 185, 129, 0.15);  color: #6EE7B7; }
:root.app-dark .badge-open       { background: rgba(245, 158, 11, 0.15);  color: #FCD34D; }
:root.app-dark .badge-inprogress { background: rgba(139, 92, 246, 0.15); color: #C4B5FD; }
:root.app-dark .badge-resolved   { background: rgba(16, 185, 129, 0.15); color: #6EE7B7; }
:root.app-dark .badge-closed     { background: rgba(107, 114, 128, 0.15); color: #9CA3AF; }
:root.app-dark .badge-active     { background: rgba(16, 185, 129, 0.15); color: #6EE7B7; }
:root.app-dark .badge-away       { background: rgba(245, 158, 11, 0.15); color: #FCD34D; }
:root.app-dark .badge-offline    { background: rgba(107, 114, 128, 0.15); color: #9CA3AF; }

/* ============================================
   TICKET DETAIL — INFO ROWS
   ============================================ */
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--color-border-subtle);
}

.info-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.info-value {
    font-size: 0.82rem;
    color: var(--color-text);
    font-weight: 600;
}

/* ============================================
   AGENT CARDS
   ============================================ */
.agent-card {
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow var(--transition), transform var(--transition);
}

.agent-card:hover {
    box-shadow: var(--shadow-glow) !important;
    transform: translateY(-3px);
}

.agent-meta-label {
    font-size: 0.68rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.agent-meta-value {
    font-size: 0.8rem;
    color: var(--color-text);
    font-weight: 500;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border-subtle);
}

.page-num {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all var(--transition);
}

/* ============================================
   EMPTY STATES & LOADING
   ============================================ */
.empty-state {
    padding: 60px 24px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   LOGIN PAGE
   ============================================ */
/* ── Dark login shell ── */
.ld-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ld-card {
    width: 100%;
    max-width: 480px;
    background: #1A1B26;
    border-radius: 22px;
    padding: 52px 48px 44px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.60);
}

/* ── Brand row ── */
.ld-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 36px;
}

.ld-brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
}

/* ── Heading ── */
.ld-title {
    font-size: 2.1rem;
    font-weight: 800;
    color: #ffffff;
    text-align: center;
    margin: 0 0 10px;
    letter-spacing: -0.6px;
    line-height: 1.1;
    font-family: var(--font-family);
}

.ld-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.42);
    text-align: center;
    margin: 0 0 36px;
    font-family: var(--font-family);
}

/* ── Fields ── */
.ld-field {
    margin-bottom: 22px;
}

.ld-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 9px;
    font-family: var(--font-family);
}

.ld-input {
    width: 100%;
    background: #13141F;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 11px;
    padding: 15px 16px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.82);
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    box-sizing: border-box;
    font-family: var(--font-family);
}

.ld-input::placeholder {
    color: rgba(255, 255, 255, 0.22);
}

.ld-input:focus {
    border-color: rgba(124, 131, 253, 0.55);
    box-shadow: 0 0 0 3px rgba(124, 131, 253, 0.12);
}

/* Password field wrapper (for eye toggle) */
.ld-input-wrap {
    position: relative;
}

.ld-input-pw {
    padding-right: 48px;
}

.ld-eye {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

/* ── Sign In button ── */
.ld-btn {
    width: 100%;
    height: 54px;
    margin-top: 10px;
    border: none;
    border-radius: 13px;
    background: linear-gradient(90deg, #6C63FF 0%, #3EC6E0 100%);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-family);
}

.ld-btn:hover:not(:disabled) {
    opacity: 0.90;
    transform: translateY(-1px);
}

.ld-btn:active:not(:disabled) {
    transform: scale(0.99) translateY(0);
}

.ld-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Spinner inside button */
.ld-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ld-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Footer links ── */
.ld-footer {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.ld-link {
    font-size: 0.83rem;
    color: rgba(255, 255, 255, 0.38);
    text-decoration: none;
    transition: color 0.18s;
    font-family: var(--font-family);
}

.ld-link:hover {
    color: rgba(255, 255, 255, 0.70);
}

.ld-demo {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.28);
    font-family: var(--font-family);
}

/* ── Error banner ── */
.ld-error {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.28);
    color: #FCA5A5;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.85rem;
    margin-bottom: 22px;
    text-align: center;
    font-family: var(--font-family);
}

/* ============================================
   UTILITY
   ============================================ */
.mb-4 { margin-bottom: 16px !important; }
.mb-6 { margin-bottom: 24px !important; }

.text-heading   { color: var(--color-heading) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-muted     { color: var(--color-text-muted) !important; }
.text-success   { color: var(--color-success) !important; }
.text-warning   { color: var(--color-warning) !important; }
.text-danger    { color: var(--color-danger) !important; }
.text-purple    { color: var(--color-purple) !important; }
.text-primary   { color: var(--color-primary) !important; }

/* ============================================
   BLAZOR ERROR UI
   ============================================ */
.blazor-error-boundary {
    background: var(--color-danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An unhandled error has occurred.";
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }
}
