/* ========================================
   FluxConsole — Premium Terminal Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Brand Colors */
    --flux-primary: #6C5CE7;
    --flux-primary-glow: rgba(108, 92, 231, 0.4);
    --flux-accent: #00E5A0;
    --flux-accent-glow: rgba(0, 229, 160, 0.3);
    --flux-danger: #FF6B6B;
    --flux-warning: #FFA502;

    /* Backgrounds */
    --bg-deep: #0A0B1A;
    --bg-card: rgba(16, 18, 38, 0.85);
    --bg-card-border: rgba(108, 92, 231, 0.15);
    --bg-input: rgba(10, 11, 26, 0.9);
    --bg-header: rgba(10, 11, 26, 0.95);
    --bg-terminal: #0D0E1C;

    /* Text */
    --text-primary: #E8E8F0;
    --text-secondary: #8B8DA3;
    --text-dim: #5A5C72;

    /* Borders */
    --border-subtle: rgba(108, 92, 231, 0.1);
    --border-active: rgba(108, 92, 231, 0.4);

    /* Spacing */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* ========== Animated Background ========== */

.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(108, 92, 231, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(0, 229, 160, 0.03) 0%, transparent 50%),
        linear-gradient(rgba(108, 92, 231, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108, 92, 231, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    z-index: 0;
    animation: gridPulse 8s ease-in-out infinite alternate;
}

@keyframes gridPulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ========== Join Page ========== */

.join-container {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.join-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    backdrop-filter: blur(20px);
    box-shadow: 
        0 0 60px rgba(108, 92, 231, 0.08),
        0 25px 50px rgba(0, 0, 0, 0.4);
    animation: cardSlideUp 0.6s ease-out;
}

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

.join-logo {
    text-align: center;
    margin-bottom: 32px;
}

.join-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--flux-primary), var(--flux-accent));
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px var(--flux-primary-glow);
}

.join-logo h1 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--flux-primary), var(--flux-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.join-logo .subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 6px;
}

.server-info {
    background: rgba(108, 92, 231, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.server-info .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--flux-accent);
    box-shadow: 0 0 10px var(--flux-accent-glow);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.server-info .server-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.server-info .server-status {
    font-size: 12px;
    color: var(--flux-accent);
    margin-left: auto;
}

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

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

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.form-group input:focus {
    border-color: var(--flux-primary);
    box-shadow: 0 0 0 3px var(--flux-primary-glow);
}

.form-group input::placeholder {
    color: var(--text-dim);
}

.btn-connect {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--flux-primary), #5A4BD1);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    letter-spacing: 0.3px;
}

.btn-connect:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--flux-primary-glow);
}

.btn-connect:active {
    transform: translateY(0);
}

.btn-connect:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.error-msg {
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--flux-danger);
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.error-msg.visible { display: block; }

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

/* ========== Console Page ========== */

.console-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--flux-primary), var(--flux-accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.header-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-session {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--flux-accent);
    box-shadow: 0 0 8px var(--flux-accent-glow);
    transition: background 0.3s, box-shadow 0.3s;
}

.connection-status .status-dot.offline {
    background: var(--flux-danger);
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}

.viewer-dropdown {
    position: relative;
    cursor: pointer;
}

.viewer-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid var(--border-subtle);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--flux-primary);
    font-weight: 500;
}

.viewer-badge svg {
    width: 14px;
    height: 14px;
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(5px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
}

.viewer-dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-title {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.dropdown-content ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dropdown-content li {
    font-size: 12px;
    color: var(--text-primary);
    padding: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-content li .user-dot {
    width: 6px;
    height: 6px;
    background: var(--flux-accent);
    border-radius: 50%;
}

/* Terminal Area */
.terminal-wrapper {
    flex: 1;
    padding: 0;
    overflow: hidden;
    background: var(--bg-terminal);
}

#terminal {
    width: 100%;
    height: 100%;
}

/* Command Input */
.command-bar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-header);
    border-top: 1px solid var(--border-subtle);
    gap: 10px;
    flex-shrink: 0;
}

.command-prefix {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--flux-primary);
    font-weight: 600;
    user-select: none;
    flex-shrink: 0;
}

.command-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.command-input:focus {
    border-color: var(--flux-primary);
    box-shadow: 0 0 0 2px var(--flux-primary-glow);
}

.command-input::placeholder {
    color: var(--text-dim);
}

.btn-send {
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--flux-primary), #5A4BD1);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

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

.btn-send:active { transform: translateY(0); }

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.3s ease-out;
    max-width: 320px;
}

.toast.error {
    border-color: rgba(255, 107, 107, 0.3);
    color: var(--flux-danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== Scrollbar ========== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 92, 231, 0.4);
}

/* ========== Loading Spinner ========== */

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-left-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ========== Responsive ========== */

@media (max-width: 600px) {
    .join-card {
        padding: 32px 24px;
    }
    .console-header {
        padding: 10px 14px;
    }
    .command-bar {
        padding: 8px 10px;
    }
    .header-session {
        display: none;
    }
}
