:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --sidebar-width: 260px;
}

body.light-mode {
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

/* Re-style sidebar for light mode to standout */
body.light-mode .sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border);
}

body.light-mode .top-bar {
    background: rgba(255, 255, 255, 0.9);
}

body.light-mode .control-group,
body.light-mode .plan-item,
body.light-mode .chat-sidebar,
body.light-mode .chat-header,
body.light-mode .chat-main {
    background: rgba(0, 0, 0, 0.05);
    /* Slight dark tint for contrast on white */
}

body.light-mode input[type="text"],
body.light-mode textarea {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
}

body.light-mode .msg-client {
    background: #e2e8f0;
    color: #0f172a;
}

/* Chat List Scroll Fix */
#chatList {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    height: calc(100% - 60px);
    /* Subtract search bar height */
}

/* Scrollbar Style */
#chatList::-webkit-scrollbar {
    width: 6px;
}

#chatList::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

#chatList::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #020617;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    transition: width 0.3s;
    /* Smooth transition */
}

.sidebar.collapsed {
    width: 60px;
    padding: 20px 10px;
}

.sidebar.collapsed h1,
.sidebar.collapsed .status-badge,
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .nav-btn {
    justify-content: center;
    font-size: 0;
    /* Hide text */
}

.sidebar.collapsed .nav-btn span {
    margin: 0;
    font-size: 1.2rem;
    /* Keep icon visible */
}

.logo {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logo h1 {
    margin: 0;
    font-size: 1.4rem;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-bar {
    height: 70px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
}

.view-section {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
    display: none;
    /* Hide by default */
}

.view-section.active {
    display: block;
}

/* Grid Systems */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card.full-height {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 600px;
    /* Fixed reasonable height */
}

h2,
h3 {
    margin-top: 0;
    color: var(--text);
}

h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Dynamic City Manager */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Forms & Controls */
.control-group {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    align-items: center;
}

input[type="text"],
textarea {
    width: 100%;
    background: #020617;
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 8px;
    box-sizing: border-box;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider.danger {
    background-color: var(--danger);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-save {
    background: var(--success);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.status-online {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status-offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Chat UI */
.chat-wrapper {
    flex: 1;
    display: flex;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
}

.chat-sidebar {
    width: 250px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--border);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
}

.chat-header {
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.msg-bot {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.msg-client {
    background: #334155;
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.chat-item {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background: var(--primary);
    color: white;
}

.chat-item .name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-item .msg {
    display: block;
    font-size: 0.8rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Plan Items */
.plan-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 2fr auto;
    gap: 10px;
    align-items: center;
}

.plan-item input {
    background: transparent;
    border: 1px solid transparent;
    padding: 5px;
}

.plan-item input:focus {
    border-color: var(--primary);
    background: #020617;
}

.remove-plan-btn {
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0 10px;
}

/* Queue Table */
.queue-table {
    width: 100%;
    border-collapse: collapse;
}

.queue-table th {
    text-align: left;
    color: var(--text-muted);
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.queue-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}