/* ============================================================
   Localhost Tunnel Dashboard — Styles
   DevOps monitoring dark mode, Grafana-inspired
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --primary: #00CEC9;
    --primary-light: #55EFC4;
    --secondary: #636E72;
    --accent: #FF6B6B;
    --bg: #0D1117;
    --bg-elevated: #161B22;
    --bg-surface: #21262D;
    --bg-card: #1C2128;
    --bg-hover: #2D333B;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #484F58;
    --border: #30363D;
    --success: #2EA043;
    --warning: #D29922;
    --danger: #F85149;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 4px 16px rgba(0, 0, 0, .4);
    --transition: 200ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.header {
    text-align: center;
    padding: 24px 0 20px;
}

.header-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: var(--text-secondary);
    font-size: .9rem;
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn:hover {
    background: var(--bg-hover);
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #000;
    font-weight: 700;
}

.btn-primary:hover {
    opacity: .9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: .8rem;
}

.btn-danger {
    background: rgba(248, 81, 73, .1);
    border-color: var(--danger);
    color: var(--danger);
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* --- Stats Bar --- */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 4px;
}

/* --- Tunnel Cards --- */
.tunnels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.tunnel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.tunnel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.up {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

.status-dot.down {
    background: var(--danger);
}

.status-dot.unknown {
    background: var(--secondary);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.tunnel-name {
    font-weight: 700;
    font-size: .95rem;
    flex: 1;
}

.tunnel-provider {
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--text-muted);
}

.tunnel-body {
    padding: 12px 14px;
}

.tunnel-url {
    font-family: var(--font-mono);
    font-size: .8rem;
    color: var(--primary);
    word-break: break-all;
    margin-bottom: 8px;
    cursor: pointer;
}

.tunnel-url:hover {
    text-decoration: underline;
}

.tunnel-meta {
    display: flex;
    gap: 12px;
    font-size: .75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.tunnel-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tunnel-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}

/* --- QR Code --- */
.qr-container {
    display: flex;
    justify-content: center;
    padding: 12px;
}

.qr-canvas {
    background: #fff;
    border-radius: 4px;
    padding: 8px;
}

/* --- Request Log --- */
.log-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    font-weight: 700;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.log-table th {
    text-align: left;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.log-table td {
    padding: 6px 14px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: .8rem;
}

.log-table tr:hover {
    background: var(--bg-hover);
}

.log-table .method {
    font-weight: 700;
}

.log-table .method.GET {
    color: var(--primary);
}

.log-table .method.POST {
    color: var(--success);
}

.log-table .method.PUT {
    color: var(--warning);
}

.log-table .method.DELETE {
    color: var(--danger);
}

.log-table .status-ok {
    color: var(--success);
}

.log-table .status-err {
    color: var(--danger);
}

.log-body {
    max-height: 300px;
    overflow-y: auto;
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .85rem;
    outline: none;
    margin-bottom: 10px;
}

.modal-input:focus {
    border-color: var(--primary);
}

/* --- Response Time Chart --- */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.chart-canvas {
    width: 100%;
    height: 120px;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: .85rem;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .tunnels-grid {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        grid-template-columns: 1fr 1fr;
    }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}