/* Kommunkollen -- Scanline design system */

:root {
    --accent:    #5ba3d9;
    --bg:        #f8fafc;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1e293b;
    --muted:     #64748b;
    --mono:      'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    --sans:      system-ui, -apple-system, sans-serif;
    --radius:    4px;
}

[data-theme="dark"] {
    --bg:        #0e1117;
    --surface:   #161b24;
    --border:    #2a3040;
    --text:      #e2e8f0;
    --muted:     #6b7a99;
}

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

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    /* height sätts via $extraHead baserat på mackan.eu-navens höjd */
}

@media (max-width: 800px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
    }
}

/* Left panel */
.panel {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
}

.tab-btn {
    flex: 1;
    padding: 10px 8px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content { display: none; flex: 1; padding: 20px; }
.tab-content.active { display: block; }

/* Search */
.search-wrap {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    font-family: var(--mono);
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

.search-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
    font-family: var(--mono);
}

.suggest-list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    z-index: 100;
    display: none;
}

.suggest-list.open { display: block; }

.suggest-item {
    padding: 8px 14px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggest-item:hover,
.suggest-item.focused { background: var(--border); }

.suggest-item .kod {
    color: var(--muted);
    font-size: 11px;
}

/* Result card */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: none;
}

.result-card.visible { display: block; }

.result-type {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.result-main {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 4px;
}

.result-sub {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 14px;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.result-field {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    position: relative;
}

.result-field label {
    display: block;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.result-field .val {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}

.copy-btn {
    position: absolute;
    top: 6px; right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    font-family: var(--mono);
}

.result-field:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); }
.copy-btn.copied { color: #4caf50; opacity: 1; }

/* Error message */
.error-msg {
    background: rgba(220, 60, 60, 0.1);
    border: 1px solid rgba(220, 60, 60, 0.3);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    color: #e88;
    display: none;
}

.error-msg.visible { display: block; }

/* Loading */
.loading-indicator {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 13px;
    display: none;
}

.loading-indicator.visible { display: block; }

/* Batch: file strip */
.file-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.file-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

/* Batch tab */
.batch-textarea {
    width: 100%;
    height: 140px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    resize: vertical;
    outline: none;
    margin-bottom: 10px;
}

.batch-textarea:focus { border-color: var(--accent); }

.batch-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.select-box {
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

.btn {
    padding: 7px 14px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    letter-spacing: 0.02em;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); opacity: 1; }

/* Batch results table */
.batch-results {
    overflow-x: auto;
    margin-top: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--mono);
}

.data-table th {
    text-align: left;
    padding: 6px 8px;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tr:hover td { background: var(--surface); }
.data-table .err { color: #e88; }

/* Map */
#map {
    height: 100%;
    min-height: 400px;
    background: var(--bg);
    position: sticky;
    top: 0;
}

.leaflet-container { background: var(--bg); }

/* API tab */
.api-endpoint {
    margin-bottom: 18px;
}

.api-endpoint h3 {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.api-url {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    word-break: break-all;
    margin-bottom: 4px;
}

.api-desc {
    font-size: 12px;
    color: var(--muted);
}

/* API tab: Testa-knapp och svarspanel */
.btn-try {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    background: none;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
    margin-left: 6px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.btn-try:hover { background: var(--accent); color: #fff; }
.btn-try:disabled { opacity: 0.4; cursor: not-allowed; }

.api-response {
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.api-response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
}

.api-response pre {
    margin: 0;
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    overflow-x: auto;
    max-height: 260px;
}

/* Snackbar */
.snackbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: var(--mono);
    font-size: 12px;
    transition: transform 0.2s ease;
    pointer-events: none;
    z-index: 10000;
}

.snackbar.show { transform: translateX(-50%) translateY(0); }

/* Share + copy-as buttons */
.share-wrap {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    align-items: center;
}

.copy-as-wrap {
    position: relative;
}

.copy-as-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 140px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.copy-as-menu button {
    display: block;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    text-align: left;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
}

.copy-as-menu button:hover { background: var(--border); }

.btn-share {
    font-size: 11px;
    padding: 5px 12px;
}

/* Leaflet popup -- Scanline-tema */
.kk-popup .leaflet-popup-content-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    padding: 0;
}

.kk-popup .leaflet-popup-content {
    margin: 10px 14px;
}

.kk-popup .leaflet-popup-tip {
    background: var(--surface);
}

.kk-popup .leaflet-popup-close-button {
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    padding: 4px 6px;
}

.kk-popup .leaflet-popup-close-button:hover {
    color: var(--text);
}
