:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --card-bg: rgba(30, 41, 59, 0.5);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --modal-bg: rgba(15, 23, 42, 0.95);
}

/* Essential Auth Check Style */
#app-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg);
    background: radial-gradient(circle at bottom right, #1e1b4b, #0f172a);
    min-height: 100vh;
    color: var(--text-main);
    display: flex;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    background: linear-gradient(to right, #fff, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-link {
    padding: 0.75rem 1rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 0.75rem;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    font-weight: 500;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-link.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.logout-btn {
    margin-top: auto;
    color: #ef4444;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    position: relative;
}

.header-actions {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.notification-bell {
    position: relative;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.2s;
}

.notification-bell:hover {
    color: white;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 50%;
    border: 2px solid var(--bg);
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--modal-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    margin-top: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1001;
    overflow: hidden;
}

.notification-dropdown.active {
    display: block;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.8rem;
    transition: background 0.2s;
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

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

.user-info h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.user-info p {
    color: var(--text-dim);
    font-size: 0.875rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 1.5rem;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(99, 102, 241, 0.4);
}

.stat-card h3 {
    color: var(--text-dim);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.stat-card .value {
    font-size: 2.25rem;
    font-weight: 700;
}

.welcome-card {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    padding: 2.5rem;
    border-radius: 2rem;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

.welcome-card h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.welcome-card p {
    opacity: 0.9;
    max-width: 600px;
}

/* Table Styles */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    overflow: hidden;
}

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

.table th {
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dim);
    border-bottom: 1px solid var(--glass-border);
}

.table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.875rem;
}

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

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-open {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-in-progress {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.badge-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-resolved {
    background: #1e293b;
    color: var(--text-dim);
}

.badge-closed {
    background: #0f172a;
    color: var(--text-dim);
    opacity: 0.5;
}

.badge-urgent {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--modal-bg);
    width: 90%;
    max-width: 700px;
    border-radius: 2rem;
    border: 1px solid var(--glass-border);
    max-height: 90vh;
    overflow-y: auto;
    padding: 2.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-dim);
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Search Bar */
.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-inner {
    flex: 1;
    position: relative;
}

/* Tabs */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
    gap: 2rem;
}

.modal-tab {
    padding: 0.75rem 0;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    position: relative;
}

.modal-tab.active {
    color: var(--primary);
}

.modal-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}

/* Tab Content Visibility */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Activity Logs */
.activity-item {
    padding: 1rem 0;
    border-left: 2px solid var(--glass-border);
    margin-left: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

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

.activity-item::before {
    content: '';
    position: absolute;
    left: -5.5px;
    top: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg);
}

.activity-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.activity-agent {
    font-weight: 600;
    color: var(--text-main);
}

.activity-time {
    color: var(--text-dim);
}

.activity-text {
    font-size: 0.875rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.comment-box {
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border-radius: 1rem;
    margin-top: 1rem;
    border: 1px solid var(--glass-border);
}

.attachment-preview {
    max-width: 100%;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    border: 1px solid var(--glass-border);
}

/* Map Section */
#map-container {
    width: 100%;
    height: 500px;
    background: #0a0a0f;
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.map-marker-caption {
    position: absolute;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -100%);
    margin-top: -4px;
    border: 1px solid var(--glass-border);
    z-index: 11;
}

.map-marker-caption-leaflet {
    background: rgba(0, 0, 0, 0.7) !important;
    border: 1px solid var(--glass-border) !important;
    color: white !important;
    font-size: 0.65rem !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    border-bottom: none !important;
}

/* Leaflet Specific Overrides */
#map-container .leaflet-tile-pane {
    filter: grayscale(1) invert(1) brightness(0.8) contrast(1.2);
}

.leaflet-container {
    background: #0a0a0f !important;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Chat Module Styles */
.chat-session-item {
    border-left: 3px solid transparent;
}

.chat-session-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.chat-session-item.active {
    background: rgba(99, 102, 241, 0.05);
    border-left-color: var(--primary);
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.chat-bubble {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

#chat-input:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}