/* === RESET & BASE === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
    --bg-base: #0b0f1a;
    --bg-surface: rgba(15, 20, 35, 0.8);
    --bg-elevated: rgba(22, 28, 48, 0.85);
    --bg-card: rgba(25, 32, 56, 0.65);
    --bg-card-solid: #151b30;
    --bg-hover: rgba(45, 55, 90, 0.5);
    --bg-input: rgba(10, 14, 28, 0.7);
    --text-primary: #eaf0ff;
    --text-secondary: #8b95b5;
    --text-muted: #505a78;
    --accent: #6c5ce7;
    --accent-2: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #6c5ce7, #a78bfa);
    --accent-glow: rgba(108, 92, 231, 0.35);
    --success: #00d68f;
    --success-glow: rgba(0, 214, 143, 0.25);
    --warning: #ffb347;
    --warning-glow: rgba(255, 179, 71, 0.2);
    --danger: #ff6b6b;
    --danger-glow: rgba(255, 107, 107, 0.25);
    --border: rgba(60, 70, 110, 0.35);
    --border-light: rgba(100, 120, 180, 0.15);
    --glass: rgba(255, 255, 255, 0.03);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated mesh gradient background */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(108, 92, 231, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(167, 139, 250, 0.08), transparent),
        radial-gradient(ellipse 50% 60% at 50% 50%, rgba(0, 214, 143, 0.04), transparent);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--accent-2); text-decoration: none; transition: color var(--transition); }
a:hover { color: #c4b5fd; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100, 120, 180, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 120, 180, 0.5); }

code {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* === LOGIN === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(108, 92, 231, 0.2), transparent 70%);
    top: -200px; right: -100px;
    animation: float 8s ease-in-out infinite;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.15), transparent 70%);
    bottom: -200px; left: -100px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.1); }
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    padding: 1px;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.3), transparent 50%, rgba(167, 139, 250, 0.2));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-header h1 {
    font-size: 32px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    pointer-events: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-sm { padding: 7px 14px; font-size: 12px; border-radius: 8px; }

.btn-success { background: linear-gradient(135deg, #00d68f, #00b377); color: #fff; box-shadow: 0 2px 12px var(--success-glow); }
.btn-danger { background: linear-gradient(135deg, #ff6b6b, #ee5a24); color: #fff; box-shadow: 0 2px 12px var(--danger-glow); }
.btn-warning { background: linear-gradient(135deg, #ffb347, #ff9f1a); color: #1a1a2e; box-shadow: 0 2px 12px var(--warning-glow); }
.btn-ghost {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-block { width: 100%; }

.error-msg {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--danger-glow);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius);
    color: var(--danger);
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}

/* === LAYOUT === */
.app {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 272px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition);
}

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

.sidebar-header img {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.sidebar-header .bot-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.2px;
}

.sidebar-header .bot-status {
    font-size: 11px;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-header .bot-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    padding: 16px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-section:first-child {
    padding-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
    font-weight: 500;
    border-radius: 10px;
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-2);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
}

.nav-item .icon {
    width: 22px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    padding: 8px 0;
    transition: color var(--transition);
}

.sidebar-footer a:hover {
    color: var(--danger);
    text-decoration: none;
}

/* --- MAIN --- */
.main {
    flex: 1;
    margin-left: 272px;
    padding: 32px 40px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* === CARDS === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(108, 92, 231, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-icon {
    font-size: 22px;
    margin-bottom: 10px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(108, 92, 231, 0.1);
    border-radius: 10px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
    transition: border-color var(--transition);
}

.card:hover {
    border-color: var(--border);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.1px;
}

.card-body {
    padding: 24px;
}

/* === TABLE === */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border-light);
    background: rgba(15, 20, 35, 0.5);
}

td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid rgba(60, 70, 110, 0.15);
    color: var(--text-secondary);
    transition: background var(--transition);
}

tr:hover td {
    background: rgba(108, 92, 231, 0.04);
}

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

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--success-glow); color: var(--success); }
.badge-danger { background: var(--danger-glow); color: var(--danger); }
.badge-warning { background: var(--warning-glow); color: var(--warning); }
.badge-info { background: rgba(108, 92, 231, 0.15); color: var(--accent-2); }

/* === SERVER STATUS === */
.server-status-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px;
}

.status-indicator {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.status-online {
    background: var(--success);
    box-shadow: 0 0 16px var(--success-glow);
    animation: pulse-status 2s ease-in-out infinite;
}

.status-offline {
    background: var(--danger);
    box-shadow: 0 0 16px var(--danger-glow);
}

@keyframes pulse-status {
    0%, 100% { box-shadow: 0 0 16px var(--success-glow); }
    50% { box-shadow: 0 0 24px rgba(0, 214, 143, 0.4); }
}

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

.server-info .meta {
    color: var(--text-muted);
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* === CONFIG EDITOR === */
.config-group {
    margin-bottom: 28px;
}

.config-group h4 {
    font-size: 13px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
}

.config-row label {
    width: 220px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.config-row input {
    flex: 1;
    max-width: 400px;
}

.config-row .config-fixed {
    flex: 1;
    max-width: 400px;
    padding: 12px 16px;
    background: rgba(15, 20, 35, 0.5);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* === GUILD LIST === */
.guild-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition);
}

.guild-card:hover {
    background: rgba(108, 92, 231, 0.06);
}

.guild-card:last-child {
    border-bottom: none;
}

.guild-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(108, 92, 231, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-2);
    flex-shrink: 0;
    overflow: hidden;
}

.guild-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.guild-info {
    flex: 1;
}

.guild-info .name {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.1px;
}

.guild-info .details {
    font-size: 12px;
    color: var(--text-muted);
}

.guild-stats {
    display: flex;
    gap: 20px;
}

.guild-stats .stat {
    text-align: center;
}

.guild-stats .stat .num {
    font-weight: 800;
    font-size: 16px;
    color: var(--text-primary);
}

.guild-stats .stat .lbl {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* === REDIS KEY LIST === */
.key-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    transition: background var(--transition);
}

.key-item:hover {
    background: rgba(108, 92, 231, 0.04);
}

.key-item .key-name {
    color: var(--accent-2);
    font-weight: 600;
}

.key-item .key-value {
    color: var(--text-secondary);
    margin-top: 4px;
    word-break: break-all;
}

.key-item .key-meta {
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 4px;
}

/* === LOADING & EMPTY === */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.loading .spinner {
    display: inline-block;
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 16px;
}

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

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 14px;
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    padding: 14px 24px;
    background: var(--bg-card-solid);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toastIn {
    from { transform: translateY(30px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* === PAGINATION === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.page-info {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* === TRANSCRIPT LIST === */
.transcript-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.transcript-item:last-child { border-bottom: none; }
.transcript-item:hover { background: rgba(108, 92, 231, 0.04); }

.transcript-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.transcript-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === LIVE LOGS === */
.log-output-container {
    padding: 0 !important;
}

.log-output {
    background: rgba(5, 8, 18, 0.9);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 16px;
    height: 520px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11.5px;
    line-height: 1.7;
}

.log-line {
    display: flex;
    gap: 10px;
    padding: 2px 0;
    border-radius: 4px;
    padding-left: 6px;
    transition: background 0.1s;
}

.log-line:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-time {
    color: #4a5568;
    flex-shrink: 0;
}

.log-level {
    flex-shrink: 0;
    font-weight: 700;
    min-width: 55px;
}

.log-msg {
    word-break: break-all;
}

.log-info .log-level { color: #63b3ed; }
.log-info .log-msg { color: #cbd5e0; }

.log-error .log-level { color: #fc8181; }
.log-error .log-msg { color: #feb2b2; }

.log-warn .log-level { color: #f6ad55; }
.log-warn .log-msg { color: #fbd38d; }

/* === BOT CONTROLS === */
.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.control-grid .card-body p {
    line-height: 1.7;
}

/* === PAGE TRANSITION === */
#pageContent {
    animation: fadeIn 0.3s ease;
}

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

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        width: 64px;
    }
    .sidebar .nav-item span:not(.icon),
    .sidebar .nav-section,
    .sidebar-header .bot-name,
    .sidebar-header .bot-status,
    .sidebar-footer {
        display: none;
    }
    .sidebar-header {
        justify-content: center;
        padding: 16px 8px;
    }
    .sidebar-header img {
        width: 36px;
        height: 36px;
    }
    .sidebar-nav {
        padding: 8px;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .nav-item.active::before {
        display: none;
    }
    .main {
        margin-left: 64px;
        padding: 20px 16px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
