/* Boligdata Admin — Supabase-inspired design */

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

:root {
    --sidebar-width: 232px;

    --sidebar-bg: #1c1c21;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: #a1a1aa;
    --sidebar-active-text: #f4f4f5;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);

    --accent: #3ecf8e;
    --accent-dark: #2db87d;

    --content-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-radius: 6px;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--sidebar-bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────── */

.admin-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    padding: 18px 14px 14px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    width: 26px;
    height: 26px;
    background: var(--accent);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-logo-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--sidebar-active-text);
    letter-spacing: -0.01em;
}

.sidebar-logo-badge {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(62, 207, 142, 0.15);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: auto;
}

.sidebar-section {
    padding: 12px 8px 8px;
    flex: 1;
}

.sidebar-section-label {
    padding: 0 8px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.6;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav-item a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 5px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 450;
    transition: background 0.1s ease, color 0.1s ease;
}

.sidebar-nav-item a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.sidebar-nav-item a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.sidebar-nav-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-nav-item a.active .sidebar-nav-icon {
    opacity: 1;
    color: var(--accent);
}

/* ── Content area ─────────────────────────────── */

.content-area {
    flex: 1;
    background: var(--content-bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Page header ──────────────────────────────── */

.page-header {
    padding: 22px 28px 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin-bottom: 3px;
}

.page-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

/* ── Page content ─────────────────────────────── */

.page-content {
    padding: 20px 28px;
    flex: 1;
}

/* ── Toolbar ──────────────────────────────────── */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input {
    padding: 6px 11px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: border-color 0.15s;
    width: 220px;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.15);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ── Card ─────────────────────────────────────── */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* ── Table ────────────────────────────────────── */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead tr {
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
}

thead th {
    padding: 9px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.08s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody td {
    padding: 11px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

.cell-muted {
    color: var(--text-secondary);
    font-size: 12px;
}

.cell-mono {
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 11.5px;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
}

/* ── Status badges ────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

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

.badge-running {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-running .badge-dot {
    background: #3b82f6;
    animation: blink 1.4s ease-in-out infinite;
}

.badge-completed {
    background: #dcfce7;
    color: #15803d;
}

.badge-completed .badge-dot {
    background: #22c55e;
}

.badge-failed {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-failed .badge-dot {
    background: #ef4444;
}

.badge-idle {
    background: #f1f5f9;
    color: #64748b;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Buttons ──────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11.5px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--content-bg);
    color: var(--text-primary);
    border-color: #cbd5e1;
}

/* ── Job name cell ────────────────────────────── */

.job-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.job-name-key {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
    font-family: 'JetBrains Mono', Consolas, monospace;
}

/* ── Trigger source ───────────────────────────── */

.trigger-badge {
    display: inline-block;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 3px;
}

.trigger-api {
    background: #eff6ff;
    color: #2563eb;
}

.trigger-schedule {
    background: #f1f5f9;
    color: #64748b;
}

.trigger-admin {
    background: #fdf4ff;
    color: #9333ea;
}

/* ── Duration cell ────────────────────────────── */

.duration-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ── Error message ────────────────────────────── */

.error-cell {
    font-size: 11.5px;
    color: #b91c1c;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'JetBrains Mono', Consolas, monospace;
}

.error-cell.expanded {
    white-space: pre-wrap;
    word-break: break-all;
    overflow: visible;
}

/* ── Refresh info ─────────────────────────────── */

.refresh-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.refresh-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: blink 2s ease-in-out infinite;
}

/* ── Loading / empty states ───────────────────── */

.loading-state,
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 32px;
    color: var(--text-muted);
    gap: 10px;
    text-align: center;
}

.loading-row td {
    padding: 24px 16px !important;
    text-align: center;
    color: var(--text-muted);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Toast notifications ──────────────────────── */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 11px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.12);
    animation: slideUp 0.2s ease;
    max-width: 340px;
    pointer-events: auto;
}

.toast-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.toast-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

@keyframes slideUp {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* ── Stats strip ──────────────────────────────── */

.stats-strip {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px 18px;
    flex: 1;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.stat-value.running { color: #2563eb; }
.stat-value.failed  { color: #dc2626; }

/* ── Form card (Find referencer) ─────────────────── */

.form-card {
    padding: 20px 24px 16px;
    margin-bottom: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px 16px;
    margin-bottom: 16px;
}

.form-group-wide {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-hint-ok {
    color: var(--accent-dark);
}

.form-error {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 5px;
    font-size: 12px;
    color: #b91c1c;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.spinner-sm {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
}

/* ── Autocomplete dropdown ────────────────────────── */

.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    box-shadow: 0 4px 16px rgb(0 0 0 / 0.10);
    overflow: hidden;
    max-height: 240px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 9px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.08s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f0fdf4;
    color: var(--accent-dark);
}

/* ── Ejendomstype badges ──────────────────────────── */

.type-badge {
    display: inline-block;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 3px;
    white-space: nowrap;
}

.type-1 {
    background: #eff6ff;
    color: #2563eb;
}

.type-2 {
    background: #fdf4ff;
    color: #9333ea;
}

.type-3 {
    background: #fff7ed;
    color: #c2410c;
}

/* ── Projected price ──────────────────────────────── */

.price-projected {
    font-weight: 500;
    color: var(--accent-dark);
}

/* ── Segmented control ────────────────────────────── */

.segmented-control {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: var(--card-bg);
}

.segmented-btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.segmented-btn:last-child {
    border-right: none;
}

.segmented-btn:hover:not(.segmented-btn-active) {
    background: var(--content-bg);
    color: var(--text-primary);
}

.segmented-btn-active {
    background: var(--accent);
    color: #fff;
}

/* ── Checkbox group ───────────────────────────────── */

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 2px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}
