:root {
    --bg-dark: #313338;
    --bg-secondary: #2b2d31;
    --bg-tertiary: #1e1f22;
    --text-main: #f2f3f5;
    --text-muted: #b5bac1;
    --border-color: #3f4147;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --danger: #ed4245;
    --danger-hover: #c03537;
    --success: #23a559;
    --success-hover: #1a7f44;
}

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

body {
    font-family: 'Inter', 'Whitney', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screens */
.screen {
    min-height: 100vh;
    display: none;
    animation: fadeIn 0.3s ease forwards;
}

.screen.active {
    display: flex;
}

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

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    background: var(--bg-tertiary);
}

.login-card {
    padding: 32px;
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.24);
    text-align: center;
}

.login-card h2 {
    margin-bottom: 8px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-main);
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 16px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

input[type="password"] {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 3px;
    background: #1e1f22;
    color: var(--text-main);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    outline: none;
}

input[type="password"]:focus {
    box-shadow: 0 0 0 1px var(--accent);
}

button {
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    border-radius: 3px;
    padding: 10px 24px;
    font-size: 14px;
    color: white;
}

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

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

.secondary-btn {
    background: #4e5058;
}

.secondary-btn:hover {
    background: #6d6f78;
}

.danger-btn {
    background: var(--danger);
}

.danger-btn:hover {
    background: var(--danger-hover);
}

.success-btn {
    background: var(--success);
}

.success-btn:hover {
    background: var(--success-hover);
}

#login-btn {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    font-size: 16px;
}

.error-text {
    color: var(--danger);
    margin-top: 12px;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* Dashboard Layout */
#dashboard-screen {
    flex-direction: row;
}

.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.sidebar-header {
    padding: 24px;
    background: var(--bg-tertiary);
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

.sidebar-header h2 {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
    margin-bottom: 16px;
}

.server-selector-wrapper select {
    width: 100%;
    padding: 8px 12px;
    background: #1e1f22;
    color: var(--text-main);
    border: none;
    border-radius: 4px;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-btn {
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    padding: 8px 12px;
    text-align: left;
    font-size: 15px;
    background: transparent;
    transition: background-color 0.1s, color 0.1s;
}

.nav-btn:hover {
    background: rgba(78, 80, 88, 0.3);
    color: var(--text-main);
}

.nav-btn.active {
    background: rgba(78, 80, 88, 0.6);
    color: var(--text-main);
}

.sidebar-footer {
    padding: 16px;
    background: #232428;
}

.sidebar-footer .danger-btn {
    width: 100%;
}

.content-area {
    flex: 1;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-bar {
    padding: 0 16px;
    height: 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-dark);
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 10;
}

#page-title {
    font-weight: 600;
    font-size: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #23a559;
}

/* Tabs */
.tab-content {
    padding: 24px;
    display: none;
    animation: fadeIn 0.2s ease;
}

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

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

.stat-card {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: none;
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

/* Cards & Tables */
.table-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.table-card h2 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

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

th {
    padding: 8px 12px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
}

td {
    padding: 12px;
    font-size: 14px;
    border-top: 1px solid var(--border-color);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
}

.badge.open, .badge.pending { background: rgba(88, 101, 242, 0.2); color: #5865f2; }
.badge.closed, .badge.rejected { background: rgba(237, 66, 69, 0.2); color: #ed4245; }
.badge.approved, .badge.accepted { background: rgba(35, 165, 89, 0.2); color: #23a559; }

.action-btns {
    display: flex;
    gap: 4px;
}

/* Chat View */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
}

.secondary-btn {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-main);
    padding: 6px 12px;
    font-size: 12px;
}

.secondary-btn:hover {
    background: var(--text-main);
    color: var(--bg-dark);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 16px;
}

.msg-avatar {
    width: 40px;
    height: 40px;
    background: #3f4147;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-content-area {
    display: flex;
    flex-direction: column;
}

.msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.msg-author {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-main);
}

.msg-timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

.msg-text {
    font-size: 15px;
    line-height: 1.375;
    white-space: pre-wrap;
    word-break: break-word;
    color: #dbdee1;
}

.chat-input-area {
    display: flex;
    padding: 16px;
    background: var(--bg-dark);
    gap: 12px;
}

.chat-input-area input {
    flex: 1;
    border: none;
    background: #383a40;
    color: var(--text-main);
    padding: 11px 16px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    outline: none;
}

/* Config Editor */
.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.config-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    flex: 1;
    min-width: 200px;
}

.config-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 2;
}

.config-select {
    flex: 1;
    padding: 8px 12px;
    background: #1e1f22;
    color: var(--text-main);
    border: none;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
}

.config-select:focus {
    box-shadow: 0 0 0 1px var(--accent);
}

.panel-form {
    padding: 24px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 24px;
}

textarea.config-select {
    resize: vertical;
    min-height: 100px;
}

code {
    background: #1e1f22;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    color: #e3e5e8;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease forwards;
}

.modal-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 8px 16px rgba(0,0,0,0.24);
}

.modal-card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-card p {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.2s ease;
    }
    .sidebar.mobile-active {
        left: 0;
    }
    .content-area {
        padding: 0;
    }
}
