/* ─────────────────────────────────────────────────────────
   Abrha Remote  ·  Dark Nebula Theme

   Every font and icon used here is served from this origin. A remote
   stylesheet can read what is typed into a page through attribute
   selectors, and a remote font tells its host that a session was opened,
   so neither is worth the convenience.
   ───────────────────────────────────────────────────────── */

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/JetBrainsMono-Regular.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/JetBrainsMono-Medium.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/JetBrainsMono-SemiBold.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/JetBrainsMono-Bold.woff2') format('woff2');
}

/* Reset */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html, body { width:100%; height:100%; overflow:hidden; }

/* ── Design Tokens ── */
:root {
    --bg:           #060a12;
    --surface:      rgba(10,16,30,0.94);
    --border:       rgba(0,210,255,0.20);
    --border-soft:  rgba(255,255,255,0.06);
    --cyan:         #00d2ff;
    --cyan-dim:     rgba(0,210,255,0.12);
    --cyan-grad:    linear-gradient(135deg, #00d2ff 0%, #3a7bd5 50%, #6366f1 100%);
    --rose:         #ff4b6b;
    --emerald:      #00f59b;
    --amber:        #ffd000;
    --text:         #f1f5f9;
    --text-muted:   #8b9dc3;
    --text-dim:     #5b6b88;
    --font-ui:      system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:    'JetBrains Mono', Menlo, Monaco, Consolas, monospace;
    --radius-card:  20px;
    --radius-input: 11px;
    --radius-btn:   11px;
    --shadow-card:  0 28px 80px rgba(0,0,0,.8), 0 0 50px rgba(0,210,255,.10);
    --shadow-glow:  0 12px 30px rgba(0,210,255,.30);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Icons ── */
.sprite-source { position:absolute; width:0; height:0; overflow:hidden; }
.icon {
    width:1em; height:1em; flex:none;
    fill:none; stroke:currentColor;
    stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;
    vertical-align:-0.125em;
}

/* ── Backdrop ── */
#particle-canvas { position:fixed; inset:0; z-index:0; pointer-events:none; }

.bg-gradient {
    position:fixed; inset:0; z-index:1; pointer-events:none;
    background:
        radial-gradient(ellipse 60% 50% at 0% 0%, rgba(0,210,255,0.10) 0%, transparent 55%),
        radial-gradient(ellipse 50% 55% at 100% 100%, rgba(99,102,241,0.12) 0%, transparent 55%),
        radial-gradient(ellipse 35% 35% at 80% 8%, rgba(244,63,94,0.06) 0%, transparent 55%);
}

/* ── App Layout ── */
.app-wrapper { position:relative; z-index:10; display:flex; flex-direction:column; height:100vh; }

/* ════════════════════ NAVBAR ════════════════════ */
.app-navbar {
    display:flex; align-items:center; justify-content:space-between;
    padding:10px 28px;
    background: rgba(6,10,18,0.88);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border-soft);
    flex-shrink:0; z-index:30;
}

.brand-badge { display:flex; align-items:center; gap:10px; text-decoration:none; }

/* The corner radius is applied here rather than trusted to the artwork, so a
   mark supplied on an opaque square does not sit as a hard rectangle against
   the navbar. */
.brand-logo {
    display:block; width:34px; height:34px;
    border-radius:24%;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08),
                0 6px 18px -6px rgba(13,139,255,0.75);
    transition: transform .25s ease, box-shadow .25s ease;
}
.brand-badge:hover .brand-logo {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.18),
                0 9px 26px -6px rgba(13,139,255,0.95);
}
.brand-pill {
    background: var(--cyan-dim); border:1px solid rgba(0,210,255,0.35);
    color:var(--cyan); font-size:0.65rem; font-weight:700;
    padding:2px 7px; border-radius:5px; letter-spacing:0.08em;
}

.nav-right { display:flex; align-items:center; gap:10px; }

.status-badge {
    display:flex; align-items:center; gap:6px;
    padding:5px 12px; background:rgba(20,30,50,0.75);
    border:1px solid rgba(255,255,255,0.08);
    border-radius:18px; font-size:11px; font-weight:600; color:#94a3b8;
}
.status-dot {
    width:7px; height:7px; border-radius:50%;
    background:var(--emerald); box-shadow:0 0 8px var(--emerald);
    transition: all .25s;
}
.status-dot.busy  { background:var(--amber);   box-shadow:0 0 8px var(--amber); }
.status-dot.error { background:var(--rose);    box-shadow:0 0 8px var(--rose); }
.status-dot.live  { background:var(--emerald); box-shadow:0 0 8px var(--emerald); }

.btn-icon {
    width:34px; height:34px; border-radius:9px;
    background:rgba(20,30,50,0.8); border:1px solid rgba(255,255,255,0.08);
    color:#94a3b8; display:flex; align-items:center; justify-content:center;
    font-size:13px; cursor:pointer; transition:all .2s;
}
.btn-icon:hover { background:rgba(30,45,70,1); color:var(--cyan); }

/* ════════════════════ MAIN ════════════════════ */
.main-content {
    flex:1; position:relative; overflow:auto;
    display:flex; align-items:center; justify-content:center;
}

/* ════════════════════ FORM PANEL ════════════════════ */
.form-panel {
    width:100%; max-width:600px;
    background: var(--surface);
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    border:1px solid var(--border);
    border-radius: var(--radius-card);
    padding:32px 38px 24px;
    box-shadow: var(--shadow-card);
    position:relative; overflow:hidden;
    margin:20px;
    animation: cardIn .35s cubic-bezier(.16,1,.3,1) both;
}
@keyframes cardIn {
    from { opacity:0; transform:scale(.97) translateY(12px); }
    to   { opacity:1; transform:scale(1)   translateY(0); }
}
.form-panel::before {
    content:''; position:absolute; top:0; left:0; right:0; height:2.5px;
    background: var(--cyan-grad);
    box-shadow: 0 0 16px var(--cyan);
}

/* Shown above the form only while a session is still running behind it. */
.btn-back {
    display:flex; align-items:center; gap:6px;
    margin-bottom:16px; padding:5px 12px 5px 9px;
    background:rgba(20,30,50,0.85); border:1px solid rgba(255,255,255,0.08);
    border-radius:8px; cursor:pointer;
    color:#8b9dc3; font-size:12px; font-weight:600;
    transition:all .2s;
}
.btn-back:hover { background:rgba(30,45,70,1); color:var(--cyan); border-color:rgba(0,210,255,0.3); }

/* ── Card Header ── */
.card-header {
    display:flex; align-items:center; gap:12px;
    margin-bottom:20px; padding-bottom:14px;
    border-bottom:1px solid var(--border-soft);
}
.card-header-icon {
    width:46px; height:46px; border-radius:12px; flex:none;
    background: var(--cyan-dim); border:1px solid rgba(0,210,255,0.35);
    color:var(--cyan); display:flex; align-items:center; justify-content:center;
    font-size:21px; box-shadow:0 4px 14px rgba(0,210,255,.18);
}
.card-header-title { font-size:19px; font-weight:800; color:#fff; letter-spacing:-0.01em; }
.card-header-subtitle { font-size:12.5px; color:var(--text-muted); margin-top:2px; }

/* ── Form Controls ── */
.form-group { margin-bottom:14px; }
.form-grid-2 { display:grid; grid-template-columns:1fr 100px; gap:12px; }
.form-label {
    display:flex; align-items:center; gap:6px;
    font-size:12px; font-weight:600; color:#94a3b8; margin-bottom:5px;
}
.form-label .icon { color:var(--cyan); }
.label-optional { color:var(--text-dim); font-size:10px; font-weight:400; }
.mb0 { margin-bottom:0; }

.ssh-input {
    width:100%; height:42px; padding:0 13px;
    background: rgba(8,14,28,0.9);
    border:1px solid var(--border-soft);
    border-radius: var(--radius-input);
    color:#e2e8f0;
    font-family: var(--font-mono);
    font-size:13.5px;
    font-weight:500;
    letter-spacing: 0.02em;
    outline:none;
    transition: border-color .2s, box-shadow .2s;
}
.ssh-input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
    letter-spacing: 0;
}
.ssh-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,210,255,0.18);
}
.ssh-input.text-center { text-align:center; }

/* Masking a plain text field keeps the credential out of the one input type
   browsers offer to remember. */
.ssh-input.masked {
    -webkit-text-security: disc;
    text-security: disc;
    letter-spacing: 0.16em;
}

/* Protocol Tabs */
.auth-row { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.auth-tabs { display:flex; gap:5px; }
.auth-tab {
    padding:5px 11px; border-radius:7px;
    background:rgba(20,30,50,0.8); border:1px solid rgba(255,255,255,0.06);
    color:var(--text-dim); font-size:11.5px; font-weight:600;
    cursor:pointer; transition:all .2s;
    display:flex; align-items:center; gap:5px;
}
.auth-tab:hover { color:var(--text-muted); border-color:rgba(255,255,255,0.12); }
.auth-tab.active {
    background:var(--cyan-dim); border-color:rgba(0,210,255,0.4);
    color:var(--cyan);
}

/* Password reveal */
.pwd-input-wrap { position:relative; }
.pwd-input-wrap .ssh-input { padding-right:40px; }
.btn-eye {
    position:absolute; right:11px; top:50%; transform:translateY(-50%);
    background:transparent; border:none; color:var(--text-dim);
    cursor:pointer; font-size:15px; padding:4px; line-height:0;
}
.btn-eye:hover { color:var(--cyan); }

/* Connect Button */
.form-actions { margin-top:4px; }
.btn-connect {
    width:100%; height:46px; border-radius:var(--radius-btn);
    background:var(--cyan-grad); border:none;
    color:#fff; font-size:14px; font-weight:700;
    display:flex; align-items:center; justify-content:center; gap:8px;
    cursor:pointer;
    box-shadow: var(--shadow-glow);
    transition: all .25s cubic-bezier(.16,1,.3,1);
    margin-top:8px;
    letter-spacing: 0.01em;
}
.btn-connect:hover { transform:translateY(-2px); box-shadow: 0 16px 35px rgba(0,210,255,.45); }
.btn-connect:active { transform:translateY(0); }
.btn-connect:disabled { opacity:0.7; cursor:not-allowed; transform:none !important; }

/* Status Message */
.status-msg { margin-top:12px; text-align:center; font-size:12.5px; font-weight:600; min-height:16px; }
.status-msg.error { color:var(--rose); }
.status-msg.busy  { color:var(--amber); }
.status-msg.live  { color:var(--cyan); }

/* Security Note */
.security-note {
    display:flex; align-items:center; justify-content:center; gap:6px;
    margin-top:16px; padding-top:14px;
    border-top:1px solid var(--border-soft);
    font-size:11px; color:var(--text-dim);
}
.security-note .icon { color:var(--emerald); }

/* ════════════════════ SESSION PANEL ════════════════════ */
.desktop-panel {
    position:absolute; inset:0;
    display:flex; flex-direction:column;
    background:#0b0f19; z-index:20;
}
.desktop-toolbar {
    height:42px; background:rgba(6,10,18,0.96);
    border-bottom:1px solid var(--border-soft);
    display:flex; align-items:center; padding:0 14px; gap:8px;
    flex-shrink:0;
}
.session-tabs { display:flex; align-items:center; gap:6px; min-width:0; }

/* One per open session. There are three at most, so each is wide enough for a
   host and port in full; only an unusually long name is cut short. */
.session-chip {
    display:flex; align-items:center; gap:7px;
    max-width:230px;
    padding:4px 11px; border-radius:7px;
    background:rgba(20,30,50,0.85); border:1px solid rgba(255,255,255,0.06);
    font-family:var(--font-mono); font-size:11.5px; font-weight:500;
    color:#8b9dc3; cursor:pointer; transition:all .2s;
}
.chip-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.session-chip:hover { background:rgba(30,45,70,1); color:#e2e8f0; }
.session-chip.active {
    color:#e2e8f0;
    border-color:rgba(0,210,255,0.35);
    background:linear-gradient(135deg, rgba(0,210,255,0.14), rgba(99,102,241,0.14));
}
.chip-proto {
    flex-shrink:0; padding:1px 5px; border-radius:4px;
    background:rgba(255,255,255,0.07);
    font-size:9px; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
    color:#94a3b8;
}
.session-chip.active .chip-proto { background:rgba(0,210,255,0.18); color:var(--cyan); }

.session-dot {
    flex-shrink:0; width:7px; height:7px; border-radius:50%;
    background:var(--emerald); box-shadow:0 0 8px var(--emerald);
}

/* Dimmed while its session is in the background, so at a glance the row shows
   which one the keyboard is going to. */
.session-chip:not(.active) .session-dot { opacity:.45; box-shadow:none; }

.toolbar-spacer { flex:1; }
.btn-tool {
    padding:4px 10px; border-radius:7px;
    background:rgba(20,30,50,0.85); border:1px solid rgba(255,255,255,0.06);
    color:#94a3b8; font-size:11px; font-weight:600;
    display:flex; align-items:center; gap:5px; cursor:pointer;
    transition:all .2s;
}
.btn-tool:hover { background:rgba(30,45,70,1); color:var(--cyan); }
.btn-tool:disabled { opacity:.5; cursor:default; }
.btn-tool:disabled:hover { background:rgba(20,30,50,0.85); color:#94a3b8; }

/* When a session drops, this is the way back. It is tinted so it reads as the
   thing to reach for rather than as one more control in the row. */
#btn-reconnect { color:var(--cyan); border-color:rgba(0,210,255,0.25); }
#btn-reconnect:hover:not(:disabled) { background:rgba(0,210,255,0.15); }
#btn-reconnect:disabled { color:var(--cyan); }
#btn-reconnect:disabled .icon { animation:tool-spin .8s linear infinite; }
@keyframes tool-spin { to { transform:rotate(360deg); } }

.btn-disconnect { color:var(--rose); border-color:rgba(255,75,107,0.25); }
.btn-disconnect:hover { background:rgba(255,75,107,0.15); color:var(--rose); }

.desktop-viewport { flex:1; position:relative; width:100%; }

/* Background sessions are hidden but keep their box. Removing them from the
   layout would collapse them to nothing, and a session told its display is
   nothing high resizes to match — then has to resize back on every switch. */
.session-frame {
    position:absolute; inset:0;
    width:100%; height:100%; border:none; background:#0b0f19;
    visibility:hidden;
}
.session-frame.visible { visibility:visible; }

/* ════════════════════ FOOTER ════════════════════ */
.app-footer {
    display:flex; align-items:center; justify-content:space-between;
    padding:7px 28px;
    background:rgba(6,10,18,0.88);
    border-top:1px solid var(--border-soft);
    font-size:11px; color:var(--text-dim); flex-shrink:0;
}
.footer-brand { color:var(--text-muted); font-weight:600; }

.hidden { display:none !important; }

/* ════════════════════ FOCUS ════════════════════ */
:focus-visible { outline:2px solid var(--cyan); outline-offset:2px; }
.ssh-input:focus-visible { outline:none; }

/* ════════════════════ RESPONSIVE ════════════════════ */
@media (max-width: 640px) {
    .form-panel { padding:24px 20px 18px; margin:12px; }
    .form-grid-2 { grid-template-columns:1fr 80px; gap:8px; }
    .app-navbar { padding:8px 14px; }
    .card-header-title { font-size:16px; }
    .footer-brand { display:none; }

    /* The toolbar has to fit three chips and four buttons. The buttons keep
       their icons and drop their labels; the chips keep their text, since a
       chip with no text says nothing about which session it is. */
    .desktop-toolbar { padding:0 8px; gap:6px; }
    .btn-tool { padding:4px 8px; }
    .session-chip { max-width:120px; padding:4px 7px; gap:5px; font-size:10.5px; }
    .chip-proto { font-size:8px; padding:1px 4px; }
    #btn-reconnect, #btn-fullscreen-session, #btn-disconnect, #btn-add-session { font-size:0; gap:0; }
    #btn-reconnect .icon, #btn-fullscreen-session .icon,
    #btn-disconnect .icon, #btn-add-session .icon { font-size:13px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    #particle-canvas { display:none; }
}
