/* =========================================================
   UniSupport — Liquid Glass Design System
   Inspired by macOS Tahoe & iOS 26
   ========================================================= */

/* ---------- CSS Variables ---------- */
:root {
    /* Color palette */
    --color-bg-1: #FFE5D9;
    --color-bg-2: #C7E4F2;
    --color-bg-3: #E0D4F7;
    --color-bg-4: #FFD6E8;

    --color-accent: #5B7CFA;
    --color-accent-2: #A47BFF;
    --color-accent-grad: linear-gradient(135deg, #5B7CFA 0%, #A47BFF 100%);

    --color-success: #34C759;
    --color-success-bg: rgba(52,199,89,0.15);
    --color-warning: #FF9500;
    --color-warning-bg: rgba(255,149,0,0.15);
    --color-danger: #FF3B30;
    --color-danger-bg: rgba(255,59,48,0.15);
    --color-info: #007AFF;
    --color-info-bg: rgba(0,122,255,0.15);

    --color-text: #1C1C1E;
    --color-text-secondary: rgba(60,60,67,0.7);
    --color-text-tertiary: rgba(60,60,67,0.5);

    /* Glass surfaces */
    --glass-bg: rgba(255,255,255,0.55);
    --glass-bg-strong: rgba(255,255,255,0.75);
    --glass-bg-subtle: rgba(255,255,255,0.35);
    --glass-border: rgba(255,255,255,0.7);
    --glass-shadow: 0 4px 24px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --glass-shadow-lg: 0 12px 48px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
    --glass-highlight: inset 0 1px 0 rgba(255,255,255,0.9);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-full: 9999px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", Menlo, Monaco, Consolas, monospace;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Sidebar */
    --sidebar-w: 240px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html, body { overflow-x: hidden; max-width: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: linear-gradient(135deg,
        var(--color-bg-1) 0%,
        var(--color-bg-2) 35%,
        var(--color-bg-3) 70%,
        var(--color-bg-4) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* Background ambient orbs */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    opacity: 0.6;
}
body::before {
    top: -10%; left: -10%;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(255,180,120,0.6), transparent 70%);
}
body::after {
    bottom: -15%; right: -10%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(140,180,255,0.5), transparent 70%);
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; }

/* ---------- Glass surfaces ---------- */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow), var(--glass-highlight);
    position: relative;
}
.glass-strong {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(50px) saturate(180%);
    -webkit-backdrop-filter: blur(50px) saturate(180%);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow-lg), var(--glass-highlight);
}
.glass-subtle {
    background: var(--glass-bg-subtle);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-md);
}

/* ---------- App layout ---------- */
.app {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    padding: 12px;
    gap: 12px;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 12px;
    height: calc(100vh - 24px);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 20px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--color-text);
}
.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--color-accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(91,124,250,0.4);
}

.sidebar-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-tertiary);
    padding: 12px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    position: relative;
}
.nav-item:hover {
    background: rgba(255,255,255,0.4);
    text-decoration: none;
}
.nav-item.active {
    background: var(--glass-bg-strong);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), var(--glass-highlight);
}
.nav-item i {
    font-size: 18px;
    color: var(--color-text-secondary);
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-item.active i { color: var(--color-accent); }
.nav-item .badge {
    margin-left: auto;
    background: var(--color-danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar-user {
    margin-top: auto;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 0.5px solid rgba(0,0,0,0.06);
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-email {
    font-size: 11px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Main content ---------- */
.main {
    flex: 1;
    min-width: 0;
    padding: 16px 20px;
    border-radius: var(--radius-xl);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
@media (max-width: 768px) {
    .topbar {
        gap: 12px;
    }
    .topbar > div:first-child {
        flex: 1 1 100%;
        min-width: 0;
    }
    .topbar-actions {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .topbar .page-title {
        font-size: 20px;
        word-break: break-word;
    }
}
.page-title {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.7px;
    margin: 0;
    color: var(--color-text);
}
.page-subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 2px 0 0;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    border: 0.5px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    box-shadow: var(--glass-highlight);
}
.btn:hover {
    background: var(--glass-bg-strong);
    transform: translateY(-1px);
    text-decoration: none;
}
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
    background: var(--color-accent-grad);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(91,124,250,0.35);
}
.btn-primary:hover {
    background: var(--color-accent-grad);
    box-shadow: 0 6px 16px rgba(91,124,250,0.45);
    color: white;
}
.btn-danger {
    background: var(--color-danger);
    color: white;
    border-color: transparent;
}
.btn-success {
    background: var(--color-success);
    color: white;
    border-color: transparent;
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--glass-bg);
}
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}
.form-control, .form-select, .form-textarea {
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    outline: none;
}
.form-control:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px rgba(91,124,250,0.15);
}
.form-textarea {
    resize: vertical;
    min-height: 100px;
}
.form-error {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 4px;
}
.form-hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

/* ---------- Cards ---------- */
.card {
    padding: 20px;
    border-radius: var(--radius-lg);
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--color-text);
    letter-spacing: -0.2px;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

/* ---------- Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: var(--glass-bg-strong);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 0.5px solid var(--glass-border);
    box-shadow: var(--glass-shadow), var(--glass-highlight);
}
.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}
.stat-icon.blue { background: rgba(91,124,250,0.15); color: var(--color-accent); }
.stat-icon.orange { background: rgba(255,149,0,0.15); color: var(--color-warning); }
.stat-icon.purple { background: rgba(164,123,255,0.15); color: var(--color-accent-2); }
.stat-icon.green { background: rgba(52,199,89,0.15); color: var(--color-success); }
.stat-icon.red { background: rgba(255,59,48,0.15); color: var(--color-danger); }

.stat-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0;
}
.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--color-text);
    margin: 4px 0 0;
    letter-spacing: -0.8px;
    line-height: 1.1;
}
.stat-delta {
    font-size: 12px;
    margin-top: 6px;
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}
.stat-delta.up { background: var(--color-success-bg); color: #0a6e3f; }
.stat-delta.down { background: var(--color-danger-bg); color: #a04a14; }

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 0.5px solid rgba(0,0,0,0.08);
}
.table td {
    padding: 14px 16px;
    border-bottom: 0.5px solid rgba(0,0,0,0.06);
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255,255,255,0.3); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}
.badge-low { background: var(--color-info-bg); color: var(--color-info); }
.badge-medium { background: rgba(91,124,250,0.15); color: var(--color-accent); }
.badge-high { background: var(--color-warning-bg); color: #a04a14; }
.badge-urgent { background: var(--color-danger-bg); color: var(--color-danger); }

.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}
.status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.status-open { background: var(--color-info-bg); color: var(--color-info); }
.status-open::before { background: var(--color-info); }
.status-in_progress { background: rgba(164,123,255,0.15); color: var(--color-accent-2); }
.status-in_progress::before { background: var(--color-accent-2); }
.status-pending { background: var(--color-warning-bg); color: #a04a14; }
.status-pending::before { background: var(--color-warning); }
.status-resolved { background: var(--color-success-bg); color: #0a6e3f; }
.status-resolved::before { background: var(--color-success); }
.status-closed { background: rgba(120,120,120,0.15); color: var(--color-text-secondary); }
.status-closed::before { background: var(--color-text-secondary); }

/* Device status */
.device-status-online { color: var(--color-success); }
.device-status-offline { color: var(--color-danger); }
.device-status-warning { color: var(--color-warning); }
.device-status-unknown { color: var(--color-text-tertiary); }

/* ---------- Flash messages ---------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.flash-success { background: var(--color-success-bg); color: #0a6e3f; }
.flash-error { background: var(--color-danger-bg); color: #a04a14; }
.flash-info { background: var(--color-info-bg); color: var(--color-info); }

/* ---------- Chat / Conversation ---------- */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}
.chat-message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeInUp 300ms ease-out;
}
.chat-message.self {
    margin-left: auto;
    flex-direction: row-reverse;
}
.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}
.chat-message.support .chat-avatar { background: linear-gradient(135deg, #34C759, #007AFF); }
.chat-message.admin .chat-avatar { background: linear-gradient(135deg, #FF9500, #FF3B30); }
.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 0.5px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.chat-message.self .chat-bubble {
    background: var(--color-accent-grad);
    color: white;
    border-color: transparent;
}
.chat-meta {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
}
.chat-message.self .chat-meta { justify-content: flex-end; }
.chat-body {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-internal {
    background: rgba(255,149,0,0.15) !important;
    border: 0.5px dashed var(--color-warning) !important;
}
.chat-system {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 8px 0;
    font-style: italic;
}

.chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 20px;
    padding: 12px;
    border-radius: var(--radius-xl);
    background: var(--glass-bg-strong);
    border: 0.5px solid var(--glass-border);
}
.chat-input textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    padding: 8px;
    min-height: 40px;
    max-height: 200px;
    color: var(--color-text);
}

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}
.empty-state-icon {
    font-size: 56px;
    color: var(--color-text-tertiary);
    margin-bottom: 16px;
}
.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--color-text);
}
.empty-state-text {
    color: var(--color-text-secondary);
    font-size: 14px;
    margin: 0 0 20px;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(91,124,250,0.2);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    body::before, body::after { display: none; }
    .app {
        padding: 0;
        gap: 0;
        flex-direction: column;
    }

    /* iOS 26 light glass pill tab bar (Apple Music style) */
    .sidebar {
        width: auto;
        max-width: calc(100vw - 80px);
        height: auto;
        position: fixed;
        bottom: 18px;
        top: auto;
        left: 12px;
        right: auto;
        flex-direction: row;
        padding: 6px;
        gap: 2px;
        z-index: 100;
        overflow: visible;
        border-radius: var(--radius-full);
        background: rgba(255, 255, 255, 0.55);
        backdrop-filter: blur(40px) saturate(180%);
        -webkit-backdrop-filter: blur(40px) saturate(180%);
        border: 0.5px solid rgba(255, 255, 255, 0.7);
        box-shadow:
            0 10px 30px rgba(0, 0, 0, 0.10),
            0 4px 12px rgba(0, 0, 0, 0.06),
            inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }

    .sidebar-brand, .sidebar-section, .sidebar-user { display: none; }

    .nav-item {
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 8px 14px;
        font-size: 11px;
        font-weight: 500;
        flex-shrink: 0;
        min-width: auto;
        text-align: center;
        color: var(--color-text-secondary);
        border-radius: var(--radius-full);
        transition: all var(--transition-fast);
        position: relative;
        white-space: nowrap;
    }
    .nav-item span {
        display: inline;
        font-size: 10px;
        line-height: 1.1;
    }
    .nav-item i {
        font-size: 22px;
        color: var(--color-text-secondary);
    }

    /* Active pill chip — lighter inset on light bar */
    .nav-item.active {
        background: rgba(255, 255, 255, 0.85);
        color: var(--color-accent);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            0 1px 3px rgba(0, 0, 0, 0.04);
    }
    .nav-item.active span {
        color: var(--color-accent);
        font-weight: 600;
    }
    .nav-item.active i {
        color: var(--color-accent);
    }

    .nav-item .badge {
        position: absolute;
        top: 4px;
        right: 8px;
        background: var(--color-danger);
        color: white;
        font-size: 10px;
        font-weight: 600;
        padding: 1px 5px;
        min-width: 16px;
        height: 16px;
        border-radius: 999px;
        margin: 0;
        border: 1.5px solid rgba(255, 255, 255, 0.95);
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Floating action button — separate light glass capsule */
    .nav-fab {
        position: fixed;
        bottom: 18px;
        right: 12px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.55);
        backdrop-filter: blur(40px) saturate(180%);
        -webkit-backdrop-filter: blur(40px) saturate(180%);
        border: 0.5px solid rgba(255, 255, 255, 0.7);
        box-shadow:
            0 10px 30px rgba(0, 0, 0, 0.10),
            0 4px 12px rgba(0, 0, 0, 0.06),
            inset 0 1px 0 rgba(255, 255, 255, 0.9);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--color-accent);
        z-index: 100;
        transition: transform var(--transition-fast);
    }
    .nav-fab:hover { transform: scale(1.05); }
    .nav-fab:active { transform: scale(0.95); }
    .nav-fab i { font-size: 24px; }

    /* On mobile, the sidebar is centered (no FAB beside it) */
    .sidebar {
        max-width: calc(100vw - 24px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .main {
        padding: 12px;
        padding-bottom: 100px;
        border-radius: 0;
    }
    .page-title { font-size: 22px; }
    .stat-value { font-size: 24px; }
    .chat-message { max-width: 90%; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Top-right user avatar (mobile) ---------- */
.user-avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 14px;
    border: 0.5px solid rgba(255,255,255,0.7);
    box-shadow:
        0 4px 12px rgba(0,0,0,0.10),
        inset 0 1px 0 rgba(255,255,255,0.3);
    cursor: pointer;
    flex-shrink: 0;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: transform var(--transition-fast);
}
.user-avatar-btn:hover { transform: scale(1.05); }
.user-avatar-btn:active { transform: scale(0.95); }

/* ---------- Glass popup modal (profile, settings) ---------- */
.popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: none !important;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 200ms ease-out;
}
.popup-backdrop.open { display: flex !important; }

.popup-sheet {
    width: 100%;
    max-width: 480px;
    margin: 16px;
    margin-bottom: 90px;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(50px) saturate(180%);
    -webkit-backdrop-filter: blur(50px) saturate(180%);
    border: 0.5px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.18),
        0 8px 24px rgba(0, 0, 0, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    padding: 18px;
    animation: slideUp 280ms cubic-bezier(0.32, 0.72, 0, 1);
}

.popup-handle {
    width: 36px;
    height: 4px;
    background: rgba(60, 60, 67, 0.25);
    border-radius: 999px;
    margin: 0 auto 14px;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 4px 16px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 8px;
}
.popup-header .user-avatar-btn {
    width: 52px;
    height: 52px;
    font-size: 20px;
    cursor: default;
}
.popup-header-info { flex: 1; min-width: 0; }
.popup-header-name {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--color-text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.popup-header-email {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 2px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popup-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}
.popup-close-btn:active {
    transform: scale(0.92);
    background: rgba(0, 0, 0, 0.06);
}

.popup-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 10px;
    border-radius: var(--radius-md);
    font-size: 15px;
    color: var(--color-text);
    text-decoration: none;
    transition: background var(--transition-fast);
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.popup-item:hover { background: rgba(255, 255, 255, 0.5); text-decoration: none; }
.popup-item:active { background: rgba(255, 255, 255, 0.7); }

.popup-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(91, 124, 250, 0.12);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
.popup-item-icon.danger {
    background: rgba(255, 59, 48, 0.12);
    color: var(--color-danger);
}
.popup-item-label {
    flex: 1;
    font-weight: 500;
}
.popup-item-chevron {
    color: var(--color-text-tertiary);
    font-size: 16px;
}

.popup-divider {
    height: 0.5px;
    background: rgba(0, 0, 0, 0.06);
    margin: 6px 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* On desktop, hide mobile-specific UI */
@media (min-width: 769px) {
    .user-avatar-btn.mobile-only,
    .popup-backdrop.mobile-only { display: none !important; }
}

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* Visibility helpers */
.mobile-only { display: none; }
@media (max-width: 768px) {
    /* Show mobile-only elements, but never override popup-backdrop's hidden state */
    .mobile-only:not(.popup-backdrop) { display: flex; }
    .desktop-only { display: none !important; }
}

/* ---------- Mobile device cards (replacing table view) ---------- */
.device-cards {
    flex-direction: column;
    gap: 8px;
}

/* Mobile profile button in nav pill - styled like other nav items */
.nav-profile-btn {
    background: transparent;
    border: none;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Site detail responsive grid */
.site-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
}
@media (max-width: 768px) {
    .site-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Ticket detail responsive grid (Conversation + Details sidebar) */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 16px;
}
@media (max-width: 768px) {
    .ticket-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Device detail responsive grid (Hardware + Warranty cards) */
.device-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 768px) {
    .device-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Global fallback — force all multi-column inline grids to single column on mobile.
   This catches any leftover [style*="grid-template-columns"] that's not 1fr only. */
@media (max-width: 768px) {
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns: 1fr 280px"],
    [style*="grid-template-columns: 1fr 300px"],
    [style*="grid-template-columns: 1fr 320px"],
    [style*="grid-template-columns: 1fr 360px"],
    [style*="grid-template-columns: 1fr 200px auto"],
    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns: 2fr 1fr 1fr"],
    [style*="grid-template-columns: 1.4fr 1fr"],
    [style*="grid-template-columns: 1.5fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}
.device-card-mobile {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    border: 0.5px solid rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: transform var(--transition-fast), background var(--transition-fast);
}
.device-card-mobile:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.65);
}
.device-card-mobile-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(91, 124, 250, 0.15);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.device-card-mobile-body {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.device-card-mobile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    margin-bottom: 2px;
}
.device-card-mobile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.device-card-mobile-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

/* ---------- Mobile ticket cards (replacing table view) ---------- */
.ticket-cards {
    flex-direction: column;
    gap: 10px;
}
.ticket-card-mobile {
    display: block;
    padding: 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    border: 0.5px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--glass-shadow);
    transition: transform var(--transition-fast), background var(--transition-fast);
}
.ticket-card-mobile:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.7);
}
.ticket-card-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}
.ticket-card-mobile-number {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-text-tertiary);
}
.ticket-card-mobile-subject {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 4px;
    line-height: 1.3;
}
.ticket-card-mobile-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}
.ticket-card-mobile-meta i {
    font-size: 12px;
}
.ticket-card-mobile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.06);
}
.ticket-card-mobile-date {
    font-size: 11px;
    color: var(--color-text-tertiary);
}
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(60,60,67,0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(60,60,67,0.4); }
