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

body {
    background-color: #0f0f13;
    color: #e0e0e0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    display: flex;
    height: 100vh;
}

/* --- Login Overlay --- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f0f13 0%, #1a1a2e 50%, #16213e 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.login-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.login-card {
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 40px;
    width: 380px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(99, 102, 241, 0.08);
    animation: cardAppear 0.4s ease-out;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.4));
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e0e0e0, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.login-subtitle {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 28px;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #aaa;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-group input::placeholder {
    color: #555;
}

.login-error {
    color: #f87171;
    font-size: 0.8rem;
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.2s ease;
    margin-bottom: 0;
}

.login-error.visible {
    min-height: 1.2em;
    max-height: 3em;
    opacity: 1;
    margin-bottom: 12px;
}

#login-btn {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

#login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

#login-btn:active {
    transform: translateY(0);
}

#login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* --- Dashboard Layout --- */
.container {
    display: flex;
    width: 100%;
}

.sidebar {
    width: 250px;
    background-color: rgba(20, 20, 30, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 10px;
    margin-bottom: 8px;
}

#device-list {
    list-style: none;
    padding: 0;
}

#device-list li {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    font-size: 0.9rem;
}

#device-list li:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

#device-list li.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-weight: 500;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ccc;
}

#logout-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #aaa;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

/* --- Terminal --- */
.terminal {
    flex: 1;
    background-color: #0a0a0f;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 12px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.log-entry {
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 5px;
}

.log-entry.streaming {
    border-left: 3px solid #4ec9b0;
    padding-left: 8px;
}

.log-header {
    font-size: 0.8em;
    margin-bottom: 4px;
}

.log-content {
    color: #d4d4d4;
    padding-left: 10px;
}

.log-content pre,
pre.log-content,
pre.stream-content {
    margin: 0;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 6px 8px;
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.streaming-indicator {
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
    color: #fff;
    background-color: #d32f2f;
    animation: pulse 1s infinite;
}

.streaming-indicator.done {
    background-color: #388e3c;
    animation: none;
}

.streaming-indicator.error {
    background-color: #f57c00;
    animation: none;
}

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

.timestamp {
    color: #555;
}

.source {
    color: #4ec9b0;
    font-weight: 600;
}

/* --- Input Area --- */
.input-area {
    display: flex;
    margin-top: 12px;
    gap: 8px;
}

#command-input {
    flex: 1;
    padding: 12px 14px;
    background-color: rgba(20, 20, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: white;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

#command-input:focus {
    border-color: #6366f1;
}

#send-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

#send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#stop-btn {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #f87171;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#stop-btn:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* --- stdin mode --- */
#command-input.stdin-mode {
    border-color: #f59e0b;
    background-color: rgba(60, 46, 20, 0.5);
}

#send-btn.stdin-mode {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
}

#send-btn.stdin-mode:hover {
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
