:root {
    /* Varion RP Palette */
    --bg-dark: #0E1116;
    /* Black Color */
    --bg-secondary: #151920;
    /* Slightly lighter for sidebar/cards (derived) */
    --bg-tertiary: #1c212b;
    /* Even lighter for inputs/hover (derived) */

    --accent: #4FB6FF;
    /* Main Color (Light Blue) */
    --accent-hover: #3a9edd;
    /* Darker shade of main for hover */

    --text-primary: #F0F9FF;
    /* White Color */
    --text-secondary: #94a3b8;
    /* Muted text (Slate-400 equivalent) */
    --text-muted: #64748b;
    /* Deeply muted (Slate-500) */

    --danger: #ef4444;
    --success: #22c55e;
    --warning: #fbbf24;

    --border: #1e2530;
    /* Border color matching the theme */
    --radius: 12px;
    /* Slightly more rounded for modern feel */
    --sidebar-width: 260px;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.nav-links {
    list-style: none;
    padding: 20px 0;
    flex: 1;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(88, 101, 242, 0.1);
    color: var(--text-primary);
    border-right: 3px solid var(--accent);
}

.nav-link i {
    width: 20px;
    text-align: center;
}

.user-profile {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.username {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    color: var(--danger);
    text-decoration: none;
    font-size: 18px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
}

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

.page-title {
    font-size: 24px;
    font-weight: 700;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: white;
}

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Activity Feed */
.section-title {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.activity-feed {
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.activity-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.activity-time {
    color: var(--text-muted);
    font-size: 12px;
    min-width: 60px;
}

.activity-content {
    flex: 1;
    font-size: 14px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(88, 101, 242, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
}

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

/* Common Components */
.btn {
    padding: 10px 20px;
    border-radius: 4px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

/* Server Header Card */
.server-header-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.server-icon-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
}

.server-details h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
}

.server-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.server-meta code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* Tabs System */
.tabs-container {
    margin-top: 2rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    background-color: rgba(0, 0, 0, 0.2);
}

.tab-btn {
    padding: 1rem 2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background-color: rgba(88, 101, 242, 0.1);
}

.tab-content {
    display: none;
    padding: 1.5rem;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Table Enhancements */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-weight: 600;
}

.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Kanban Board */
.tickets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    height: calc(100vh - 150px);
}

.ticket-column {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.column-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tickets-list {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Ticket Card */
.ticket-card {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ticket-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: var(--accent);
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.ticket-id {
    font-family: monospace;
    background: rgba(88, 101, 242, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

.ticket-user {
    color: var(--text-secondary);
}

.ticket-body p {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 0.5rem 0;
    line-height: 1.4;
}

.ticket-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticket-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ticket-actions {
    display: flex;
    gap: 0.5rem;
}

.ticket-claimed {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.badge {
    background-color: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.badge-success {
    background-color: rgba(64, 192, 87, 0.2);
    color: var(--success);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background-color: var(--bg-dark);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.btn-claim:hover {
    background-color: rgba(64, 192, 87, 0.2);
    color: var(--success);
    border-color: var(--success);
}

.btn-close:hover {
    background-color: rgba(250, 82, 82, 0.2);
    color: var(--danger);
    border-color: var(--danger);
}

/* Utilities */
.p-3 {
    padding: 1rem;
}

.p-4 {
    padding: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.rounded {
    border-radius: var(--radius);
}

.bg-secondary {
    background-color: var(--bg-secondary);
}

.bg-tertiary {
    background-color: var(--bg-tertiary);
}

.border {
    border: 1px solid var(--border);
}

.text-sm {
    font-size: 0.875rem;
}

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

.text-accent {
    color: var(--accent);
}

.text-success {
    color: var(--success);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.2s;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    position: relative;
}

.close-modal {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

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

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

.detail-group {
    margin-bottom: 1.5rem;
}

.detail-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.detail-group p {
    font-size: 1rem;
    color: var(--text-primary);
}

.description-box {
    background-color: var(--bg-dark);
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    line-height: 1.5;
}

.modal-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 6px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Chat History */
.chat-history-container {
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-loading {
    text-align: center;
    color: var(--text-muted);
    margin-top: 2rem;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.2s;
}

/* We don't distinguish self/others yet in JS logic clearly, but if we did: */
.chat-message.self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--bg-tertiary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.chat-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}


.chat-bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.chat-bubble {
    background-color: #2b323b;
    padding: 10px 14px;
    border-radius: 12px;
    border-top-left-radius: 2px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #f1f5f9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

.chat-message.self .chat-bubble {
    background-color: var(--accent);
    color: #0E1116;
    font-weight: 500;
    border-top-left-radius: 12px;
    border-top-right-radius: 2px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Mentions */
.mention {
    background: rgba(88, 101, 242, 0.3);
    color: #a5b4fc;
    padding: 0 4px;
    border-radius: 4px;
    font-size: 0.9em;
}

.chat-message.self .mention {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
    font-weight: bold;
}

.chat-attachment {
    max-width: 250px;
    border-radius: 8px;
    margin-top: 5px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.chat-attachment:hover {
    transform: scale(1.02);
}


.chat-attachment:hover {
    transform: scale(1.02);
}

/* Message Sender Styles */

/* =================== */
/* LIGHT THEME         */
/* =================== */
[data-theme="light"] {
    --bg-dark: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f6f8;
    --accent: #2980b9;
    --accent-hover: #2471a3;
    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --danger: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --border: #e2e8f0;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: #f0f2f5;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

/* =================== */
/* THEME TOGGLE BTN    */
/* =================== */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    margin: 0 12px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* =================== */
/* MOBILE BURGER       */
/* =================== */
.burger-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-card);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .burger-btn {
        display: block;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 60px 16px 16px !important;
    }
}

/* =================== */
/* GLOBAL SEARCH       */
/* =================== */
.global-search {
    position: relative;
    margin: 0 12px 12px;
}

.global-search input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
}

.global-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.global-search>i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 11px;
}

.global-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 300;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: none;
}

.global-search-results.open {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.search-result-item .sr-type {
    color: var(--text-muted);
    font-size: 10px;
    margin-left: auto;
}