/*
 * AF-Portal — design inspirerad av internetport.se
 * Mörkblå/cyan-palett, rena ytor, mjuka skuggor, kompakta paneler.
 */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e2e6ef;
    --text: #0f1a36;
    --muted: #6b7390;
    --primary: #0057ff;
    --primary-dark: #0040c2;
    --accent: #00b4d8;
    --dark: #0a1a3d;
    --success: #1f9d55;
    --warning: #d97706;
    --danger: #d33245;
    --shadow: 0 2px 12px rgba(20, 30, 70, 0.06);
    --shadow-lg: 0 8px 28px rgba(10, 26, 61, 0.10);
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------------- Header / nav ---------------- */
.site-header {
    background: var(--dark);
    color: #fff;
    border-bottom: 3px solid var(--primary);
}
.site-header a { color: #fff; }
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 68px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 8px;
    font-size: 17px;
    color: #fff;
}
.brand-text { letter-spacing: 0.2px; }

.site-nav { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.site-nav a {
    padding: 8px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
}
.site-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}
.site-nav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.site-nav .nav-cta {
    background: var(--primary);
    color: #fff;
    margin-left: 8px;
}
.site-nav .nav-cta:hover { background: var(--primary-dark); }
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    font-size: 13px;
}
.user-chip .avatar {
    width: 26px; height: 26px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: #fff;
}

/* ---------------- Hero ---------------- */
.hero {
    background: linear-gradient(135deg, #0a1a3d 0%, #0057ff 60%, #00b4d8 100%);
    color: #fff;
    padding: 48px 0 36px;
    margin-bottom: 32px;
}
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.2px; }
.hero-sub { margin: 0; font-size: 16px; opacity: 0.95; max-width: 720px; }
.hero-meta {
    margin-top: 18px;
    display: flex; gap: 18px; flex-wrap: wrap;
    font-size: 13px;
}
.hero-meta span { opacity: 0.85; }
.hero-meta strong { font-weight: 600; }

/* Klientväljare i hero (när åf har flera kopplade konton) */
.client-switcher {
    margin-top: 18px;
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.12);
    padding: 6px 6px 6px 14px;
    border-radius: 999px;
    backdrop-filter: blur(6px);
}
.client-switcher label { font-size: 12px; opacity: 0.85; }
.client-switcher select {
    background: #fff; color: var(--text);
    border: none; border-radius: 999px;
    padding: 6px 12px; font-size: 13px; font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* ---------------- Tiles / dashboard ---------------- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 36px;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 8px;
    position: relative; overflow: hidden;
}
.tile::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--primary);
}
.tile.tile-accent::before { background: var(--accent); }
.tile.tile-success::before { background: var(--success); }
.tile.tile-warning::before { background: var(--warning); }
.tile.tile-danger::before { background: var(--danger); }

.tile-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--muted); font-weight: 700;
}
.tile-value { font-size: 30px; font-weight: 700; color: var(--text); }
.tile-meta { font-size: 13px; color: var(--muted); }
.tile a { font-weight: 600; }

/* ---------------- Panels / cards ---------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    overflow: hidden;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 17px; }
.panel-head .panel-sub { color: var(--muted); font-size: 13px; }
.panel-body { padding: 24px; }
.panel-body.tight { padding: 0; }

/* ---------------- Tables ---------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--muted); font-weight: 700;
    background: #f8f9fc;
}
.data-table tbody tr:hover { background: #fafbfe; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.badge-active   { background: #e1f5ea; color: var(--success); }
.badge-upcoming { background: #fff4e0; color: var(--warning); }
.badge-ended    { background: #fde2e6; color: var(--danger); }
.badge-draft    { background: #ede9fe; color: #6d28d9; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px; font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #eef1f8; color: var(--text); border-color: #e2e6ef; }
.btn-secondary:hover { background: #dde2ec; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-ghost:hover { background: #f0f5ff; text-decoration: none; }
.btn-danger { background: #fde2e6; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.btn-small { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Forms ---------------- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid label,
.form-stack label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 13px; font-weight: 600;
}
.form-grid .full { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    width: 100%;
}
textarea { resize: vertical; min-height: 100px; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.15);
}
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.form-hint { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------------- Auth ---------------- */
.auth-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(1200px 600px at 0% -10%, rgba(0,180,216,0.18), transparent 50%),
        radial-gradient(1200px 600px at 110% 110%, rgba(0,87,255,0.20), transparent 50%),
        linear-gradient(180deg, #0a1a3d 0%, #06122c 100%);
    padding: 24px;
}
.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}
.auth-card .auth-brand {
    display: flex; align-items: center; gap: 10px; margin-bottom: 24px;
    font-weight: 700; font-size: 17px; color: var(--text);
}
.auth-card .auth-brand .brand-mark { width: 36px; height: 36px; font-size: 18px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card .auth-sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn-primary { justify-content: center; padding: 12px; font-size: 15px; }
.auth-footer { text-align: center; margin-top: 22px; font-size: 13px; color: var(--muted); }

/* ---------------- Alerts ---------------- */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: #e1f5ea; color: #0e6b3b; border-color: #bfe7cf; }
.alert-error   { background: #fde2e6; color: #a4172a; border-color: #f5b9c2; }
.alert-info    { background: #e6f0ff; color: #0a3a99; border-color: #c4d6f9; }
.alert-warning { background: #fff4e0; color: #8a4b00; border-color: #f5d7a3; }

/* ---------------- Empty state ---------------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}
.empty-state.small { padding: 32px 20px; }
.empty-state h2, .empty-state h3 { margin-top: 0; }
.empty-state .muted { color: var(--muted); }

/* ---------------- Misc ---------------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.flex { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, "Cascadia Code", "Roboto Mono", monospace; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ---------------- Impersonation banner ---------------- */
.impersonation-banner {
    background: linear-gradient(90deg, #fff4e0 0%, #ffe1b3 100%);
    border-bottom: 1px solid #f0c46a;
    color: #6b4416;
    padding: 10px 0;
    font-size: 13px;
}
.impersonation-inner {
    display: flex; align-items: center; gap: 14px;
}
.impersonation-icon {
    font-size: 18px; color: var(--warning);
}
.impersonation-banner .btn {
    margin-left: auto;
    background: #fff;
    border: 1px solid #f0c46a;
    color: #6b4416;
}
.impersonation-banner .btn:hover {
    background: #6b4416;
    color: #fff;
    border-color: #6b4416;
}

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 22px 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    margin-top: 60px;
}

/* Detalj-rader: titel/värde-grid */
.kv {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px 16px;
    font-size: 14px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* Ticket-tråd */
.ticket-thread { display: flex; flex-direction: column; gap: 14px; }
.ticket-msg {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: #fff;
}
.ticket-msg.staff { background: #f0f5ff; border-color: #c7d8ff; }
.ticket-msg .ticket-meta {
    display: flex; justify-content: space-between; gap: 8px;
    font-size: 12px; color: var(--muted);
    margin-bottom: 6px;
}
.ticket-msg .ticket-body { white-space: pre-wrap; font-size: 14px; }

@media (max-width: 820px) {
    .form-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 24px; }
    .header-inner { flex-direction: column; height: auto; padding: 12px 0; gap: 12px; }
    .site-nav { flex-wrap: wrap; justify-content: center; }
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 10px 12px; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dt { font-size: 12px; }
}
