/* ---------------------------------------------------------------------------
   Ignite Dashboard — Modern Theme
   --------------------------------------------------------------------------- */

:root {
    --bg: #ffffff;
    --bg-surface: #1a1d27;
    --bg-card: #21242f;
    --bg-card-header: #272b38;
    --bg-input: #2a2e3b;
    --border: #2e3345;
    --border-light: #363b4e;
    --text: #e1e4eb;
    --text-secondary: #8b90a0;
    --text-muted: #5c6178;
    --accent: #4f8ff7;
    --accent-hover: #3b7be6;
    --green: #34c759;
    --green-dim: #1a3a2a;
    --red: #ff453a;
    --red-dim: #3a1a1a;
    --yellow: #ffd60a;
    --yellow-dim: #3a3218;
    --orange: #ff9f0a;
    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.35);
    --transition: 0.15s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
.header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text);
}
.header-actions { display: flex; gap: 8px; }
.header-actions button {
    padding: 7px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    transition: all var(--transition);
}
.btn-start-all {
    background: var(--green);
    color: #fff;
}
.btn-stop-all {
    background: var(--red);
    color: #fff;
}
.btn-start-all:hover { background: #2db84e; box-shadow: 0 0 12px rgba(52,199,89,0.3); }
.btn-stop-all:hover  { background: #e63b31; box-shadow: 0 0 12px rgba(255,69,58,0.3); }
.btn-start-all:disabled, .btn-stop-all:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---- Tab bar ---- */
.tab-bar {
    display: flex;
    background: var(--bg-surface);
    padding: 0 28px;
    gap: 0;
    border-bottom: 1px solid var(--border);
}
.tab {
    padding: 11px 22px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    font-size: 13px;
    transition: all var(--transition);
    user-select: none;
    position: relative;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab .status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
}
.dot-online  { background: var(--green); box-shadow: 0 0 6px rgba(52,199,89,0.4); }
.dot-offline { background: var(--red); box-shadow: 0 0 6px rgba(255,69,58,0.4); }
.dot-unknown { background: var(--text-muted); }

/* ---- Content ---- */
.content {
    padding: 20px 28px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ---- Map state bar ---- */
.map-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.map-bar .map-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}
.map-state {
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.state-Active   { background: var(--green-dim); color: var(--green); border: 1px solid rgba(52,199,89,0.25); }
.state-Loaded,
.state-Stopped  { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255,214,10,0.2); }
.state-Unloaded { background: rgba(255,255,255,0.04); color: var(--text-muted); border: 1px solid var(--border); }

.map-bar .actions { margin-left: auto; display: flex; gap: 6px; }
.map-bar .actions button {
    padding: 5px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all var(--transition);
}
.map-bar .actions button:hover {
    background: var(--border-light);
    color: var(--text);
    border-color: var(--text-muted);
}
.map-bar .actions button:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* ---- Port pair cards ---- */
.port-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.port-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}
.port-card:hover {
    border-color: var(--border-light);
}
.port-card-header {
    padding: 9px 16px;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Direction row ---- */
.direction-row {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
.direction-row:last-child { border-bottom: none; }

.dir-label {
    font-weight: 600;
    font-size: 11px;
    color: var(--accent);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ---- Impairment controls ---- */
.imp-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.imp-group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.imp-group label {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color var(--transition);
}
.imp-group label:hover { color: var(--text); }

/* Toggle switch */
.toggle {
    position: relative;
    width: 30px;
    height: 16px;
    flex-shrink: 0;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle .slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.toggle .slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    left: 1px;
    top: 1px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition);
}
.toggle input:checked + .slider {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle input:checked + .slider::before {
    transform: translateX(14px);
    background: #fff;
}

.imp-group input[type="number"] {
    width: 56px;
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
    text-align: right;
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}
.imp-group input[type="number"]:focus {
    border-color: var(--accent);
}
.imp-group input[type="number"]:disabled {
    background: var(--bg-surface);
    color: var(--text-muted);
}
.imp-group .unit {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 14px;
}

/* Jitter (now inline) */
.imp-group select {
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--bg-input);
    color: var(--text);
    max-width: 170px;
    outline: none;
    transition: border-color var(--transition);
    cursor: pointer;
}
.imp-group select:focus { border-color: var(--accent); }
.imp-group select:disabled {
    background: var(--bg-surface);
    color: var(--text-muted);
}

/* Separator between impairment groups */
.imp-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    flex-shrink: 0;
}

/* Apply button */
.btn-apply {
    margin-left: auto;
    padding: 5px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all var(--transition);
}
.btn-apply:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 10px rgba(79,143,247,0.3);
}
.btn-apply:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---- Stats row ---- */
.stats-row {
    padding: 7px 16px;
    background: var(--bg-card-header);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 28px;
}
.stats-row .stat-val {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ---- Offline notice ---- */
.offline-notice {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

/* ---- Toast notifications ---- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.25s ease;
    max-width: 380px;
    backdrop-filter: blur(8px);
}
.toast-success {
    background: rgba(52,199,89,0.9);
    border: 1px solid rgba(52,199,89,0.5);
}
.toast-error {
    background: rgba(255,69,58,0.9);
    border: 1px solid rgba(255,69,58,0.5);
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Spinner ---- */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
