/* ═══════════════════════════════════════════════════════
   ServerAI Manager — Professional Theme
   ═══════════════════════════════════════════════════════ */

:root {
    /* Blue Gradient Professional Theme */
    --bg-primary: #ffffff;
    --bg-secondary: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1e40af 100%);
    --bg-sidebar: #0a1628;
    --bg-sidebar-hover: #122a4e;
    --bg-sidebar-active: #1e3a5f;
    --bg-tertiary: #f1f5f9;
    --bg-chat: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: #e2e8f0;
    --bg-active: #dbeafe;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-muted: #64748b;
    --border: #e2e8f0;
    --border-sidebar: rgba(255,255,255,.1);
    --accent: #2563eb;
    --accent-hover: #3b82f6;
    --accent-light: #dbeafe;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 24px rgba(0,0,0,.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all .2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
}

/* ── App Layout ─────────────────────────────────── */
.rc-app {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ── Left Sidebar ───────────────────────────────── */
.rc-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-sidebar);
    border-right: none;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 20;
}
.rc-sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; border: none; }

.rc-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-sidebar);
}
.rc-sidebar-header .rc-btn-icon { color: var(--text-sidebar); }
.rc-sidebar-header .rc-btn-icon:hover { background: var(--bg-sidebar-hover); }
.rc-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
}

.rc-new-chat {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 12px 8px;
    padding: 10px 16px;
    background: rgba(255,255,255,.15);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}
.rc-new-chat:hover { background: rgba(255,255,255,.25); }

.rc-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}
.rc-conv-list::-webkit-scrollbar { width: 4px; }
.rc-conv-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.rc-conv-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-sidebar-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 12px 8px 4px;
}

.rc-conv-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text-sidebar);
    position: relative;
}
.rc-conv-item:hover { background: var(--bg-sidebar-hover); color: #ffffff; }
.rc-conv-item.active { background: var(--bg-sidebar-active); color: #ffffff; }
.rc-conv-item .rc-conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rc-conv-item .rc-conv-delete {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,.4);
    cursor: pointer;
    padding: 2px;
    font-size: 14px;
}
.rc-conv-item:hover .rc-conv-delete { display: block; }
.rc-conv-item .rc-conv-delete:hover { color: #fca5a5; }

.rc-sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border-sidebar);
}
.rc-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.rc-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.rc-user-detail { display: flex; flex-direction: column; min-width: 0; }
.rc-username {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
}
.rc-role-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
}
.rc-role-badge.admin { background: rgba(99,102,241,.2); color: #818cf8; }
.rc-role-badge.viewer { background: rgba(245,158,11,.2); color: #fbbf24; }

.rc-btn-logout {
    display: flex;
    padding: 8px;
    color: rgba(255,255,255,.5);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.rc-btn-logout:hover { color: #fca5a5; background: rgba(239,68,68,.15); }

/* ── Main Area ──────────────────────────────────── */
.rc-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
}

.rc-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
}
.rc-main-header .rc-btn-icon { color: #ffffff; }
.rc-main-header .rc-btn-icon:hover { background: rgba(255,255,255,.15); }
.rc-chat-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    color: #ffffff;
}
.rc-header-actions { display: flex; gap: 8px; }
.rc-machine-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rc-mobile-menu { display: none; }

/* ── Chat Area ──────────────────────────────────── */
.rc-chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.rc-chat-area::-webkit-scrollbar { width: 6px; }
.rc-chat-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.rc-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}
.rc-welcome-icon { margin-bottom: 20px; opacity: .8; }
.rc-welcome h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.rc-welcome p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}
.rc-welcome-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 500px;
}
.rc-welcome-examples button {
    padding: 10px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}
.rc-welcome-examples button:hover {
    background: #dbeafe;
    color: #1e40af;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37,99,235,.15);
}

/* ── Messages ───────────────────────────────────── */
.rc-messages {
    flex: 1;
    padding: 20px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.rc-msg {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: msgFadeIn .3s ease;
}
@keyframes msgFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.rc-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.rc-msg.user .rc-msg-avatar { background: var(--accent); color: #fff; }
.rc-msg.assistant .rc-msg-avatar { background: #10b981; color: #fff; }

.rc-msg-content {
    flex: 1;
    min-width: 0;
}
.rc-msg-sender {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}
.rc-msg.user .rc-msg-sender { color: var(--accent-hover); }
.rc-msg.assistant .rc-msg-sender { color: var(--success); }

.rc-msg-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
}
.rc-msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Result blocks */
.rc-result {
    margin-top: 8px;
    padding: 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--success);
    border: 1px solid #e2e8f0;
    border-left: 3px solid var(--success);
}
.rc-result.error { border-left-color: var(--error); }
.rc-result-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
.rc-result-output {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* Loading dots */
.rc-loading {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}
.rc-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s ease-in-out infinite;
}
.rc-loading span:nth-child(2) { animation-delay: .2s; }
.rc-loading span:nth-child(3) { animation-delay: .4s; }
@keyframes dotPulse { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

/* Error message block */
.rc-error-msg {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #dc2626;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-line;
}

/* ── Input Area ─────────────────────────────────── */
.rc-input-area {
    padding: 12px 20px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}
.rc-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.rc-input-wrap:focus-within { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.rc-input-wrap textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #1e293b;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    min-height: 24px;
}
.rc-input-wrap textarea::placeholder { color: #94a3b8; }

.rc-input-wrap button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.rc-input-wrap button:hover { background: var(--accent-hover); }
.rc-input-wrap button:disabled { opacity: .4; cursor: not-allowed; }

.rc-input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}
.rc-viewer-hint { color: var(--warning); }

/* ── Right Sidebar ──────────────────────────────── */
.rc-right-sidebar {
    width: 0;
    min-width: 0;
    overflow: hidden;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}
.rc-right-sidebar.open { width: 300px; min-width: 300px; }

.rc-right-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
}
.rc-right-header h3 { font-size: 15px; font-weight: 600; color: #1e293b; }

.rc-machines-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.rc-machine-card {
    padding: 14px;
    margin: 6px 0;
    background: #ffffff;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.rc-machine-card:hover { border-color: #2563eb; box-shadow: 0 2px 8px rgba(37,99,235,.12); }
.rc-machine-card.offline { opacity: .5; }

.rc-machine-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.rc-machine-ip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}
.rc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}
.rc-status-dot.offline { background: var(--error); }
.rc-status-dot.unknown { background: var(--text-muted); }

.rc-machine-name {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.rc-machine-stats { display: flex; flex-direction: column; gap: 6px; }
.rc-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}
.rc-stat-label { width: 30px; color: var(--text-muted); font-weight: 500; }
.rc-stat-bar {
    flex: 1;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}
.rc-stat-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width .5s ease;
}
.rc-stat-bar-fill.low { background: var(--success); }
.rc-stat-bar-fill.mid { background: var(--warning); }
.rc-stat-bar-fill.high { background: var(--error); }
.rc-stat-val { width: 32px; text-align: right; color: var(--text-secondary); }

.rc-machine-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
}
.rc-machine-delete:hover { color: var(--error); }

/* ── Buttons ────────────────────────────────────── */
.rc-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.rc-btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.rc-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.rc-btn-sm:hover { background: var(--accent-hover); }

.rc-btn-primary {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.rc-btn-primary:hover { background: var(--accent-hover); }

.rc-btn-secondary {
    padding: 10px 20px;
    background: transparent;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}
.rc-btn-secondary:hover { background: #f1f5f9; }

/* ── Modal ──────────────────────────────────────── */
.rc-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.rc-modal-overlay.open { display: flex; }

.rc-modal {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    width: 90%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
}
.rc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}
.rc-modal-header h3 { color: #1e293b; }
.rc-modal-header h3 { font-size: 16px; font-weight: 600; }
.rc-modal-body { padding: 20px; }
.rc-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
}

.rc-form-group { margin-bottom: 14px; }
.rc-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.rc-form-group input {
    width: 100%;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: #1e293b;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}
.rc-form-group input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.rc-form-row { display: flex; gap: 12px; }
.rc-form-row .rc-form-group { flex: 1; }

/* ── Toast ──────────────────────────────────────── */
.rc-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rc-toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
    animation: toastIn .3s ease;
    min-width: 250px;
}
.rc-toast.success { background: #065f46; color: #6ee7b7; }
.rc-toast.error { background: #7f1d1d; color: #fca5a5; }
.rc-toast.info { background: #1e40af; color: #ffffff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }

/* ── Login Page ─────────────────────────────────── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f2847 0%, #1e3a5f 30%, #2563eb 70%, #1e40af 100%);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border: none;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { margin-bottom: 16px; }
.login-brand h1 { font-size: 24px; font-weight: 700; color: #1e293b; }
.login-subtitle { font-size: 14px; color: #64748b; margin-top: 4px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
}
.login-form input {
    width: 100%;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: #1e293b;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}
.login-form input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.btn-primary, .btn-block {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }

.login-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 13px;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}
.login-divider span { padding: 0 12px; }

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px solid #dadce0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.btn-google:hover { background: #f8f9fa; box-shadow: 0 2px 8px rgba(0,0,0,.2); }

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: #94a3b8;
}

.alert-error {
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #dc2626;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
    .rc-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 30;
        box-shadow: var(--shadow);
    }
    .rc-sidebar.open { left: 0; }
    .rc-right-sidebar.open { width: 100%; min-width: 100%; position: fixed; top: 0; bottom: 0; right: 0; z-index: 30; }
    .rc-mobile-menu { display: flex; }
    .rc-messages { padding: 12px; }
}
