/* ============================================
   COSMOS CONNECT OVERLAY
   SSH Tunnel modal for mobile/PWA
   ============================================ */

#connect-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #05070e;
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(180, 74, 255, 0.08) 0%, transparent 50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
#connect-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Starfield dots */
#connect-overlay::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 30% 65%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 90% 75%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 15% 85%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 45% 50%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.5), transparent);
    animation: connectStars 8s linear infinite;
    pointer-events: none;
}
@keyframes connectStars {
    0% { transform: translateY(0); }
    100% { transform: translateY(-20px); }
}

/* Glassmorphism card */
.connect-card {
    position: relative;
    width: 90%;
    max-width: 380px;
    padding: 32px 28px;
    background: rgba(10, 14, 30, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.15), 0 0 80px rgba(180, 74, 255, 0.08);
    z-index: 1;
}
/* Scanline overlay */
.connect-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 16px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 212, 255, 0.02) 2px,
        rgba(0, 212, 255, 0.02) 4px
    );
    pointer-events: none;
}

/* Close button */
.connect-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    z-index: 2;
}
.connect-close:hover {
    color: rgba(255,255,255,0.7);
}

/* Title */
.connect-title {
    font-family: 'Orbitron', monospace;
    font-size: 1.3rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 2px;
    background: linear-gradient(135deg, #00d4ff, #b44aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}
.connect-subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    color: rgba(0, 212, 255, 0.5);
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

/* Status bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.status-bar .status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-bar.disconnected {
    background: rgba(255, 60, 60, 0.1);
    border: 1px solid rgba(255, 60, 60, 0.3);
    color: #ff6b6b;
}
.status-bar.disconnected .status-dot { background: #ff3c3c; }
.status-bar.connecting {
    background: rgba(240, 160, 48, 0.1);
    border: 1px solid rgba(240, 160, 48, 0.3);
    color: #f0a030;
}
.status-bar.connecting .status-dot {
    background: #f0a030;
    animation: statusPulse 1s infinite;
}
.status-bar.connected {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: #00ff88;
}
.status-bar.connected .status-dot {
    background: #00ff88;
    animation: statusPulse 2s infinite;
}
.status-bar.error {
    background: rgba(255, 60, 60, 0.15);
    border: 1px solid rgba(255, 60, 60, 0.5);
    color: #ff3c3c;
}
.status-bar.error .status-dot { background: #ff3c3c; }
@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 4px currentColor; }
    50% { box-shadow: 0 0 12px currentColor; }
}

/* Error message */
.error-msg {
    display: none;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: rgba(255, 60, 60, 0.1);
    border: 1px solid rgba(255, 60, 60, 0.4);
    border-radius: 6px;
    color: #ff6b6b;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
}
.error-msg.visible { display: block; }

/* Form */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(0, 212, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}
.form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    background: rgba(5, 7, 14, 0.8);
    border: 1px solid rgba(0, 212, 255, 0.25);
    border-radius: 8px;
    color: #e0f0ff;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}
.form-input::placeholder {
    color: rgba(0, 212, 255, 0.25);
}
.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group { flex: 1; }

/* Input wrapper with icon */
.input-wrapper {
    position: relative;
}
.input-wrapper .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0.5;
}
.input-wrapper .form-input {
    padding-left: 36px;
}

/* Buttons */
.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn-connect {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-family: 'Orbitron', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s;
    background: linear-gradient(135deg, #00d4ff, #b44aff);
    color: #05070e;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}
.btn-connect:hover {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.6);
    transform: translateY(-1px);
}
.btn-connect:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-disconnect {
    flex: 1;
    padding: 12px;
    border: 1px solid rgba(255, 60, 60, 0.5);
    border-radius: 10px;
    font-family: 'Orbitron', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s;
    background: rgba(255, 60, 60, 0.15);
    color: #ff3c3c;
}
.btn-disconnect:hover {
    background: rgba(255, 60, 60, 0.25);
    box-shadow: 0 0 15px rgba(255, 60, 60, 0.3);
}

/* SSH fallback */
.ssh-fallback {
    display: none;
    margin-top: 16px;
    padding: 12px;
    background: rgba(180, 74, 255, 0.08);
    border: 1px solid rgba(180, 74, 255, 0.25);
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}
.ssh-fallback.visible { display: block; }
.ssh-cmd {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    color: #00d4ff;
    word-break: break-all;
    cursor: pointer;
}
.ssh-cmd:hover {
    background: rgba(0, 212, 255, 0.1);
}
.btn-copy {
    margin-top: 8px;
    padding: 6px 16px;
    background: rgba(180, 74, 255, 0.2);
    border: 1px solid rgba(180, 74, 255, 0.4);
    border-radius: 6px;
    color: #b44aff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover {
    background: rgba(180, 74, 255, 0.3);
}

/* Header connect button */
#btn-connect-tunnel {
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.4);
    color: #00d4ff;
    padding: 6px 14px;
    border-radius: 8px;
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s;
    white-space: nowrap;
}
#btn-connect-tunnel:hover {
    background: rgba(0, 212, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}
#btn-connect-tunnel.connected {
    background: rgba(0, 255, 136, 0.15);
    border-color: rgba(0, 255, 136, 0.4);
    color: #00ff88;
}
#btn-connect-tunnel.connecting {
    background: rgba(240, 160, 48, 0.15);
    border-color: rgba(240, 160, 48, 0.4);
    color: #f0a030;
    animation: statusPulse 1s infinite;
}