/* MdsSocket Admin — Soft Green Eye-Friendly Theme */

:root {
    --bg-body: #f4f7f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1b2e28;
    --bg-sidebar-hover: #243b34;
    --bg-sidebar-active: #2d4a3f;
    --bg-input: #f0f5f2;
    --bg-topbar: #ffffff;
    --border: #d4e4db;
    --border-light: #e8f0ec;
    --text-primary: #2d3b36;
    --text-secondary: #5f7a6e;
    --text-muted: #8fa89b;
    --text-sidebar: #a8c4b8;
    --text-sidebar-active: #ffffff;
    --accent: #3d9970;
    --accent-hover: #2d7a56;
    --accent-light: #e8f5ee;
    --danger: #d9534f;
    --danger-light: #fde8e8;
    --warning: #e8a838;
    --warning-light: #fff8ec;
    --success: #3d9970;
    --success-light: #e8f5ee;
    --info: #4a90a4;
    --info-light: #e8f4f8;
    --sidebar-width: 240px;
}

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.875rem;
    overflow-x: hidden;
}

/* ─── Layout ─────────────────────────────────────────── */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-topbar {
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-light);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* ─── Sidebar ────────────────────────────────────────── */

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    color: #a8e6c3;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(168, 196, 184, 0.5);
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.82rem;
    border-radius: 0;
    transition: all 0.15s;
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: #d4f0e0;
}

.sidebar-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-left: 3px solid var(--accent);
    padding-left: calc(1.25rem - 3px);
}

.sidebar-link i {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-sidebar);
    font-size: 0.8rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-sidebar-active);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.75rem;
}

/* ─── Topbar ─────────────────────────────────────────── */

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

/* ─── Cards ──────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 1.1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.1rem;
}

/* ─── Stat Widgets ───────────────────────────────────── */

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(61, 153, 112, 0.08);
    transform: translateY(-1px);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-icon-green { background: var(--success-light); color: var(--success); }
.stat-icon-blue { background: var(--info-light); color: var(--info); }
.stat-icon-orange { background: var(--warning-light); color: var(--warning); }
.stat-icon-red { background: var(--danger-light); color: var(--danger); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ─── Tables ─────────────────────────────────────────── */

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    padding: 0.65rem 0.85rem;
}

.table td {
    vertical-align: middle;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 0.82rem;
}

.table-hover tbody tr:hover {
    background: var(--accent-light);
}

/* ─── Buttons ────────────────────────────────────────── */

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
}

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

.btn-sm {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.82rem;
}

/* ─── Forms ──────────────────────────────────────────── */

.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.84rem;
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.15rem rgba(61, 153, 112, 0.12);
    color: var(--text-primary);
}

.form-control-sm, .form-select-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
}

.form-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.invalid-feedback {
    font-size: 0.72rem;
}

/* ─── Badges ─────────────────────────────────────────── */

.badge {
    font-size: 0.68rem;
    font-weight: 500;
    border-radius: 4px;
    padding: 0.25em 0.55em;
}

.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: #f0f0f0; color: #999; }
.badge-admin { background: var(--warning-light); color: #b87333; }
.badge-client { background: var(--success-light); color: var(--success); }
.badge-impersonate { background: var(--warning-light); color: var(--warning); }

/* ─── Code / API Key ─────────────────────────────────── */

code {
    background: none;
    color: var(--accent-hover);
    padding: 0;
    border-radius: 0;
    font-size: 0.78rem;
}

pre {
    background: var(--bg-sidebar);
    color: #a8e6c3;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: 0.78rem;
    overflow-x: auto;
}

/* ─── Modals ─────────────────────────────────────────── */

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.modal-header {
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 0.75rem 1.25rem;
}

.modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── SweetAlert ─────────────────────────────────────── */

.swal2-popup {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.swal2-title { color: var(--text-primary) !important; font-size: 1.1rem !important; }
.swal2-html-container { color: var(--text-secondary) !important; }

.swal2-input, .swal2-textarea {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 6px !important;
}

.swal2-confirm { background: var(--accent) !important; border-radius: 6px !important; }

/* ─── Skeleton Loader ────────────────────────────────── */

.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--bg-body) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    height: 1rem;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Page Header ────────────────────────────────────── */

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

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ─── Empty State ────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* ─── Scrollbar ──────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Responsive ─────────────────────────────────────── */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
}

@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

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

    .app-main {
        margin-left: 0;
    }

    .btn-sidebar-toggle {
        display: block;
    }
}

/* ─── Utilities ──────────────────────────────────────── */

.text-accent { color: var(--accent) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.bg-accent-light { background: var(--accent-light) !important; }

/* ─── CodeMirror Override ────────────────────────────── */

.CodeMirror {
    height: auto;
    min-height: 80px;
    max-height: 200px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
}

/* ─── Playground Log ─────────────────────────────────── */

.playground-log {
    max-height: 450px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.76rem;
}

.log-entry {
    padding: 0.4rem 0.85rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.log-entry:hover {
    background: var(--accent-light);
}

.log-entry.success { color: var(--success); }
.log-entry.error { color: var(--danger); }
.log-entry.info { color: var(--info); }

.log-time {
    color: var(--text-muted);
    min-width: 65px;
}

.log-dir {
    font-weight: 600;
    min-width: 16px;
}

/* ─── Playground Chat ────────────────────────────────── */

.chat-messages {
    height: 280px;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.chat-msg {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    max-width: 85%;
    font-size: 0.82rem;
    word-wrap: break-word;
}

.chat-msg.sent {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
}

.chat-msg.received {
    background: var(--bg-input);
    color: var(--text-primary);
    align-self: flex-start;
}

.chat-msg.system {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    align-self: center;
    font-style: italic;
}

.chat-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.chat-msg.sent .chat-meta {
    color: rgba(255,255,255,0.7);
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-light);
}
