/* EvE-FleetRoutes — main stylesheet */
:root {
    --bg: #0d1117;
    --bg-surface: #161b22;
    --bg-card: #1c2128;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --danger: #f85149;
    --success: #3fb950;
    --warning: #d29922;
    --sec-hi: #2ea043;
    --sec-low: #d29922;
    --sec-null: #f85149;
    --sec-wh: #58a6ff;
    --radius: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.navbar .logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    text-decoration: none;
}
.navbar nav { display: flex; align-items: center; gap: 1rem; }
.navbar nav a { color: var(--text-muted); text-decoration: none; font-size: .9rem; }
.navbar nav a:hover { color: var(--text); }
.user-info { color: var(--text-muted); font-size: .85rem; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: .4rem .8rem;
    font-size: .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: .2rem .5rem; font-size: .78rem; }
.btn-lg { padding: .6rem 1.2rem; font-size: 1rem; }

/* ── Utility ────────────────────────────────────────────── */
.text-warning { color: var(--warning); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

/* ── Container ──────────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
.container:has(.route-page) { max-width: 100%; padding: 0; }

/* ── Landing ────────────────────────────────────────────── */
.landing { text-align: center; padding: 8rem 1rem; }
.landing h1 { font-size: 2.4rem; margin-bottom: 2rem; }
.sso-img { height: 30px; vertical-align: middle; }

/* ── Route Page ─────────────────────────────────────────── */
.route-page { display: grid; grid-template-columns: 280px 1fr; gap: 0; min-height: calc(100vh - 60px); }

.route-controls {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 1rem;
}
.controls-toggle { display: none; width: 100%; }
.controls-inner { display: block; }

.route-controls label { display: block; margin: .3rem 0; font-size: .88rem; cursor: pointer; }
.route-controls fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem;
    margin: .8rem 0;
}
.route-controls legend { font-size: .82rem; color: var(--text-muted); padding: 0 .4rem; }
.sub-options { padding-left: 1.2rem; }
.form-group { margin-bottom: .8rem; position: relative; }
.form-group label { font-size: .82rem; color: var(--text-muted); margin-bottom: .2rem; }
.form-group input[type="text"] {
    width: 100%;
    padding: .4rem .6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: .9rem;
}

/* ── Autocomplete ───────────────────────────────────────── */
.autocomplete-wrap { position: relative; flex: 0 0 auto; min-width: 180px; }
.autocomplete-wrap input[type="text"] { width: 100%; box-sizing: border-box; }
.autocomplete-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    width: 100%;
    min-width: 220px;
}
.autocomplete-list:empty { display: none; }
.autocomplete-list li { padding: .4rem .6rem; cursor: pointer; font-size: .85rem; }
.autocomplete-list li:hover, .autocomplete-list li.active { background: var(--accent); color: #000; }
.sec-tag { font-size: .78rem; margin-left: .3rem; }
.sec-hi { color: #2ea043; }
.sec-low { color: #d29922; }
.sec-null { color: #f85149; }
.system-meta { color: var(--text-muted); font-size: .78rem; }

/* ── Route Results ──────────────────────────────────────── */
.route-results { padding: 1rem; overflow-y: auto; }
.placeholder-text { color: var(--text-muted); text-align: center; padding: 3rem 1rem; }

.route-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .6rem;
    transition: border-color .15s;
}
.route-card:hover { border-color: var(--accent); }
.card-summary { padding: .8rem 1rem; cursor: pointer; }
.card-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.card-jumps { font-weight: 600; font-size: .9rem; }
.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--text-muted); margin-top: .3rem; }
.card-expand { transition: transform .2s; }
.route-card.expanded .card-expand { transform: rotate(180deg); }
.card-detail { display: none; padding: 0 1rem 1rem; overflow-x: auto; }
.route-card.expanded .card-detail { display: block; }
.route-card.expanded { border-color: var(--accent); }

.pill {
    display: inline-block;
    padding: .15rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 10px;
    margin-right: .3rem;
    border: none;
    color: #fff;
}
.pill-via_thera, .pill-via_turnur { background: var(--sec-wh); }
.pill-via_jb { background: #da70d6; }
.pill-via_wh { background: var(--sec-wh); }
.pill-capital { background: var(--warning); color: #000; }
.pill-titan_bridge { background: var(--warning); color: #000; }
.pill-blops_bridge { background: #a371f7; }
.pill-carrier_conduit { background: #39d2e0; color: #000; }
.pill-gates_only { background: #555; }

.sec-squares { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: .4rem; }
.sec-sq { display: inline-block; width: 18px; height: 18px; border-radius: 3px; cursor: default; transition: transform .1s; }
.sec-sq:hover { transform: scale(1.3); z-index: 1; }
.sec-sq-hi  { background: var(--sec-hi); }
.sec-sq-low { background: var(--sec-low); }
.sec-sq-null { background: var(--sec-null); }
.sec-sq-wh  { background: var(--sec-wh); }

.card-bottleneck { font-size: .78rem; color: var(--text-muted); }

/* ── Inline Route Path ──────────────────────────────────── */
.route-path {
    display: flex;
    align-items: center;
    gap: 0;
    padding: .8rem 0;
    min-width: max-content;
}
.rp-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}
.rp-node::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-surface);
    margin-bottom: 4px;
}
.rp-node.sec-dot-hi::before { border-color: var(--sec-hi); background: var(--sec-hi); }
.rp-node.sec-dot-low::before { border-color: var(--sec-low); background: var(--sec-low); }
.rp-node.sec-dot-null::before { border-color: var(--sec-null); background: var(--sec-null); }
.rp-node { margin: 0 2px; }
.rp-name { font-size: .75rem; white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.rp-sec { font-size: .65rem; color: var(--text-muted); }

.rp-conn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 60px;
    height: 2px;
    margin: 0 6px;
    margin-bottom: 18px;
    flex-shrink: 0;
}
.rp-conn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    transform: translateY(-50%);
}
.rp-conn-label {
    position: relative;
    z-index: 1;
    font-size: .65rem;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Connection type colors */
.conn-gate::before { background: var(--text-muted); }
.conn-gate .rp-conn-label { border-color: #555; color: #8b949e; }
.conn-jb::before { background: #da70d6; }
.conn-jb .rp-conn-label { border-color: #da70d6; color: #da70d6; }
.conn-wh::before { background: var(--sec-wh); }
.conn-wh .rp-conn-label { border-color: var(--sec-wh); color: var(--sec-wh); }
.conn-blops::before { background: #a371f7; }
.conn-blops .rp-conn-label { border-color: #a371f7; color: #a371f7; }
.conn-titan::before { background: var(--warning); }
.conn-titan .rp-conn-label { border-color: var(--warning); color: var(--warning); }
.conn-conduit::before { background: #39d2e0; }
.conn-conduit .rp-conn-label { border-color: #39d2e0; color: #39d2e0; }

.route-warnings { margin-top: .6rem; }
.route-warning { font-size: .78rem; color: var(--warning); padding: .2rem 0; }

/* ── WH Popout ──────────────────────────────────────────── */
.wh-popout {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    z-index: 200;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.wh-popout h4 { margin-bottom: .5rem; font-size: .9rem; }
.wh-popout p { margin: .25rem 0; font-size: .85rem; }
.rp-conn.conn-wh { cursor: help; }
.rp-conn.conn-wh:hover { filter: brightness(1.3); }
.wh-cap-table { width: 100%; font-size: .82rem; border-collapse: collapse; }
.wh-cap-table th, .wh-cap-table td { padding: .25rem .5rem; border-bottom: 1px solid var(--border); }
.wh-cap-table th { text-align: left; color: var(--text-muted); }
.wh-no-data { font-size: .82rem; color: var(--text-muted); font-style: italic; margin: .4rem 0 0; }

/* ── Data Tables ────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: .5rem; }
.data-table th { text-align: left; padding: .5rem .6rem; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 500; }
.data-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
.data-table .empty { color: var(--text-muted); text-align: center; padding: 1.5rem; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 1rem;
}
.card h3 { margin-bottom: .5rem; }
.card-actions { display: flex; gap: .5rem; margin-top: .6rem; }

/* ── Admin Grid ─────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s;
}
.admin-card:hover { border-color: var(--accent); }
.admin-card h3 { color: var(--accent); margin-bottom: .3rem; }
.admin-card p { color: var(--text-muted); font-size: .9rem; }

/* ── Forms ──────────────────────────────────────────────── */
.toolbar { margin-bottom: .8rem; display: flex; gap: .5rem; }
.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    padding: .8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.inline-form input, .inline-form select {
    padding: .35rem .5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: .85rem;
}
.inline-form .form-group { margin-bottom: 0; }

.error { color: var(--danger); }
.progress-bar-container { margin-top: .5rem; }

/* ── Progress bar ───────────────────────────────────────── */
.progress-container { margin-top: 1rem; }
.progress-bar-track {
    height: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent, #3b82f6);
    transition: width .4s ease;
    min-width: 0;
}
.progress-text {
    margin-top: .35rem;
    font-size: .85rem;
    color: var(--text-secondary, #999);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15em .55em;
    font-size: .8rem;
    border-radius: 4px;
    color: #fff;
    background: #666;
}
.badge-success { background: #16a34a; }
.badge-info    { background: #2563eb; }
.badge-danger  { background: #dc2626; }

/* ── Alert ──────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: 4px;
    margin-top: .75rem;
    font-size: .9rem;
}
.alert-info {
    background: rgba(37,99,235,.12);
    border: 1px solid rgba(37,99,235,.3);
    color: var(--text);
}

/* ── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    .route-page { grid-template-columns: 1fr; }
    .route-controls { border-right: none; border-bottom: 1px solid var(--border); }
    .controls-toggle { display: block; }
    .controls-inner { display: none; }
    .route-controls.open .controls-inner { display: block; }
}

@media (max-width: 640px) {
    .navbar { flex-direction: column; gap: .5rem; }
    .navbar nav { flex-wrap: wrap; justify-content: center; }
    .landing h1 { font-size: 1.6rem; }
    .admin-grid { grid-template-columns: 1fr; }
}
