/* ============================================
   HIVE TICKETS DASHBOARD — STYLES
   Color palette from brand: deep navy bg,
   blue-to-purple gradient, soft glow accents
   ============================================ */

:root {
    --bg-darkest: #080a14;
    --bg-dark: #0d0f1a;
    --bg-card: #12152a;
    --bg-card-hover: #181c38;
    --bg-sidebar: #0a0c18;
    --bg-input: #1a1e3a;
    --border: #1e2347;
    --border-light: #2a2f5a;
    --text-primary: #e8eaf6;
    --text-secondary: #8b90b8;
    --text-muted: #5a5f88;
    --accent-blue: #6b8cff;
    --accent-purple: #9b7aed;
    --accent-green: #4ade80;
    --accent-orange: #fb923c;
    --accent-red: #f87171;
    --accent-cyan: #67e8f9;
    --gradient-brand: linear-gradient(135deg, #6b8cff 0%, #9b7aed 100%);
    --gradient-glow: linear-gradient(135deg, rgba(107,140,255,0.15) 0%, rgba(155,122,237,0.15) 100%);
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-glow: 0 0 40px rgba(107,140,255,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
    --font-main: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background: var(--bg-darkest);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
}

::selection {
    background: rgba(107,140,255,0.3);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* ============================================
   LOADING SCREEN
   ============================================ */

#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-darkest);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-hex {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.loader-hex svg {
    animation: hexPulse 2s ease-in-out infinite;
}

.loader-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 2px solid transparent;
    border-top-color: var(--accent-blue);
    border-right-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loader-sub {
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 300;
}

@keyframes hexPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
}

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

/* ============================================
   LOGIN SCREEN
   ============================================ */

#login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-darkest);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.login-container {
    position: relative;
}

.login-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(107,140,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.login-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px;
    text-align: center;
    max-width: 400px;
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.login-logo {
    margin-bottom: 20px;
}

.login-card h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-weight: 300;
}

.btn-discord {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #5865F2;
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(88,101,242,0.3);
}

.btn-discord:hover {
    background: #4752c4;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(88,101,242,0.4);
}

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

#dashboard {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

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

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.server-selector {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.server-selector select {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.server-selector select:focus {
    border-color: var(--accent-blue);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.15s ease;
    position: relative;
}

.nav-item:hover {
    background: var(--gradient-glow);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-glow);
    color: var(--accent-blue);
    border-left: 3px solid var(--accent-blue);
}

.nav-item.active .nav-icon {
    filter: drop-shadow(0 0 6px rgba(107,140,255,0.4));
}

.nav-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-tag {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

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

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: var(--bg-darkest);
    position: relative;
}

.main-content::before {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(107,140,255,0.04) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

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

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* ============================================
   STAT CARDS
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-card);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: rgba(107,140,255,0.12); }
.stat-icon.purple { background: rgba(155,122,237,0.12); }
.stat-icon.green { background: rgba(74,222,128,0.12); }
.stat-icon.orange { background: rgba(251,146,60,0.12); }

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.1;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ============================================
   CARDS & CONTENT GRID
   ============================================ */

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 32px 16px;
    font-size: 0.9rem;
}

/* ============================================
   DATA TABLES
   ============================================ */

.tickets-table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table thead th {
    background: var(--bg-sidebar);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: background 0.15s;
}

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

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BADGES & STATUS
   ============================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.open {
    background: rgba(74,222,128,0.12);
    color: var(--accent-green);
}

.status-badge.closed {
    background: rgba(248,113,113,0.12);
    color: var(--accent-red);
}

.status-badge.claimed {
    background: rgba(107,140,255,0.12);
    color: var(--accent-blue);
}

.status-badge.online {
    background: rgba(74,222,128,0.12);
    color: var(--accent-green);
}

.status-badge.offline {
    background: rgba(248,113,113,0.12);
    color: var(--accent-red);
}

/* ============================================
   PANELS GRID
   ============================================ */

.panels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s;
}

.panel-card:hover {
    border-color: var(--accent-blue);
}

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

.panel-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.panel-channel {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

.category-tree {
    margin-top: 12px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 0;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.category-item .cat-emoji {
    font-size: 1.1rem;
}

.category-item .cat-name {
    flex: 1;
}

.category-item .cat-role {
    color: var(--accent-blue);
    font-size: 0.78rem;
}

.category-indent {
    margin-left: 24px;
}

/* ============================================
   STAFF STATS
   ============================================ */

.staff-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.staff-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s;
}

.staff-card:hover {
    border-color: var(--accent-purple);
}

.staff-rank {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: var(--font-mono);
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 36px;
    text-align: center;
}

.staff-card-info {
    flex: 1;
}

.staff-card-name {
    font-weight: 600;
    font-size: 1rem;
}

.staff-card-stats {
    display: flex;
    gap: 16px;
    margin-top: 6px;
}

.staff-stat {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.staff-stat span {
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-name {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}

.setting-desc {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 2px;
}

.setting-input-group {
    display: flex;
    gap: 8px;
}

.setting-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    width: 200px;
    outline: none;
    transition: border-color 0.2s;
}

.setting-input:focus {
    border-color: var(--accent-blue);
}

.btn-sm {
    background: var(--gradient-brand);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-sm:hover {
    opacity: 0.85;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 13px;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: rgba(107,140,255,0.3);
    border-color: var(--accent-blue);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: var(--accent-blue);
}

/* ============================================
   SEARCH INPUT
   ============================================ */

.search-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.9rem;
    width: 280px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--accent-blue);
}

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

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
}

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

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ============================================
   TICKET LIST (Overview sidebar)
   ============================================ */

.ticket-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.ticket-list-item:last-child {
    border-bottom: none;
}

.ticket-list-item:hover {
    background: var(--bg-card-hover);
}

.ticket-list-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-blue);
}

.ticket-list-cat {
    flex: 1;
    font-size: 0.9rem;
}

.ticket-list-time {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Staff list item */
.staff-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.staff-list-item:last-child {
    border-bottom: none;
}

.staff-list-rank {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-purple);
    min-width: 24px;
}

.staff-list-name {
    flex: 1;
    font-size: 0.9rem;
}

.staff-list-count {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================
   TRANSCRIPT MESSAGES (Modal)
   ============================================ */

.transcript-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.transcript-meta-item {
    background: var(--bg-input);
    padding: 12px;
    border-radius: var(--radius-sm);
}

.transcript-meta-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.transcript-meta-value {
    font-weight: 600;
    margin-top: 4px;
    font-size: 0.9rem;
}

.transcript-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.transcript-msg {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    line-height: 1.5;
}

.transcript-msg:hover {
    background: var(--bg-input);
}

.transcript-msg-time {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    margin-right: 8px;
}

.transcript-msg-author {
    font-weight: 600;
    color: var(--accent-blue);
    margin-right: 8px;
}

.transcript-msg-content {
    color: var(--text-primary);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    font-size: 0.9rem;
    box-shadow: var(--shadow-card);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        min-width: 60px;
    }
    .sidebar-title, .nav-item span:last-child,
    .user-details, .server-selector, .sidebar-header {
        display: none;
    }
    .sidebar-nav { padding: 12px 6px; }
    .nav-item { justify-content: center; padding: 12px; }
    .sidebar-footer { padding: 8px; }
    .user-info { justify-content: center; }
    .btn-logout { display: none; }
    .main-content { padding: 20px; }
    .content-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .search-input { width: 180px; }
}
