/* ads.danielfrank.dk — delt design-fundament.
   Daniels egne farver (#ed36bf primær / #74195c sekundær). Mobile-first,
   ingen frameworks/build-step — matcher flådekonventionen. */

/* Poppins, selv-hostet (public/fonts/) - ingen Google Fonts-CDN-kald ved
   sidevisning, kun latin-undersættet (4 vægte, ~31KB samlet), matcher
   flådens "ingen eksterne afhængigheder ved runtime"-princip. */
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/poppins-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/poppins-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/poppins-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/poppins-700.woff2') format('woff2');
}

:root {
    --color-primary: #ED36BF;
    --color-primary-hover: #D21EA3;
    --color-primary-contrast: #ffffff;
    --color-primary-soft: #FCE4F6;
    --color-secondary: #74195C;

    --color-bg: #ffffff;
    --color-surface: #F5F5FA;
    --color-surface-raised: #ffffff;
    --color-border: #E3E3EC;
    --color-text: #17171F;
    --color-text-muted: #62626F;

    --color-success: #16803C;
    --color-success-soft: #DCFCE5;
    --color-danger: #C0362C;
    --color-danger-soft: #FBE1DE;
    --color-warning: #93650A;
    --color-warning-soft: #FDF0CE;

    --radius-sm: 5px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;

    --shadow-sm: 0 1px 2px rgba(23, 23, 31, 0.06), 0 1px 1px rgba(23, 23, 31, 0.04);
    --shadow-md: 0 8px 24px rgba(23, 23, 31, 0.08), 0 2px 6px rgba(23, 23, 31, 0.05);

    --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --header-height: 64px;
}

[data-theme="dark"] {
    --color-primary: #F25FCE;
    --color-primary-hover: #F584DA;
    --color-primary-contrast: #1A0316;
    --color-primary-soft: #3D1030;
    --color-secondary: #A6438A;

    --color-bg: #121218;
    --color-surface: #1A1A22;
    --color-surface-raised: #1F1F29;
    --color-border: #2E2E3A;
    --color-text: #F1F1F6;
    --color-text-muted: #A2A2B3;

    --color-success: #4ADE80;
    --color-success-soft: #123322;
    --color-danger: #F1897E;
    --color-danger-soft: #3A1A17;
    --color-warning: #F4C752;
    --color-warning-soft: #3A2E0C;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-primary: #F25FCE;
        --color-primary-hover: #F584DA;
        --color-primary-contrast: #1A0316;
        --color-primary-soft: #3D1030;
        --color-secondary: #A6438A;

        --color-bg: #121218;
        --color-surface: #1A1A22;
        --color-surface-raised: #1F1F29;
        --color-border: #2E2E3A;
        --color-text: #F1F1F6;
        --color-text-muted: #A2A2B3;

        --color-success: #4ADE80;
        --color-success-soft: #123322;
        --color-danger: #F1897E;
        --color-danger-soft: #3A1A17;
        --color-warning: #F4C752;
        --color-warning-soft: #3A2E0C;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
}

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

html, body { margin: 0; padding: 0; }

/* Form controls don't inherit font-family from body by default in any
   browser - without this, every <button>/<input>/<select>/<textarea> not
   explicitly styled (login/register submit buttons, .btn everywhere,
   one-off inputs outside .form-grid like admin/sites.php's price field)
   silently falls back to the OS UI font instead of Poppins. */
button, input, select, textarea { font-family: inherit; }

body {
    font-family: var(--font-sans);
    background: var(--color-surface);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--color-primary); }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 var(--space-4); }
h2 { font-size: 1.15rem; margin: 0 0 var(--space-3); }
h3 { font-size: 1rem; margin: 0 0 var(--space-2); }

/* ---- Layout shells (topbar + main), shared by both header templates ---- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 0 var(--space-4);
    height: var(--header-height);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
}
.topbar__brand svg { color: var(--color-primary); flex: none; }
.topbar__nav { display: flex; align-items: center; gap: var(--space-4); }
.topbar__nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.topbar__nav a:hover { color: var(--color-text); }
.topbar__nav a.is-active { color: var(--color-secondary); font-weight: 700; }
.topbar__toggle {
    display: none;
    background: none;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
    color: var(--color-text);
}

@media (max-width: 640px) {
    .topbar__toggle { display: block; }
    .topbar__nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: var(--space-2) 0;
    }
    .topbar__nav.is-open { display: flex; }
    .topbar__nav a { padding: var(--space-2) var(--space-4); width: 100%; }
}

.main { flex: 1 0 auto; width: 100%; max-width: 1100px; margin: 0 auto; padding: var(--space-5) var(--space-4); }

/* ---- Shared components ---- */

.card {
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}
.card h2 { margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
th { color: var(--color-text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    border: none;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--color-primary-hover); }
.btn:active { transform: translateY(1px); }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn--secondary:hover { background: var(--color-border); }
.btn--danger { background: var(--color-danger); }
.btn--danger:hover { filter: brightness(0.92); }
.btn--ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn--ghost:hover { color: var(--color-text); border-color: var(--color-text-muted); }
.btn--sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn--block { width: 100%; justify-content: center; }

.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: var(--radius-pill); font-size: 0.76rem; font-weight: 600; }
.badge--active { background: var(--color-success-soft); color: var(--color-success); }
.badge--draft { background: var(--color-surface); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge--paused { background: var(--color-warning-soft); color: var(--color-warning); }
.badge--archived { background: var(--color-border); color: var(--color-text-muted); }
.badge--expired { background: var(--color-danger-soft); color: var(--color-danger); }
.badge--pending_review { background: var(--color-warning-soft); color: var(--color-warning); }

form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-grid label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--color-text-muted); font-weight: 500; }
.form-grid input, .form-grid select, .form-grid textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.field-full { grid-column: 1 / -1; }
.field-hint { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.3rem; }

.flash { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: var(--space-3); font-size: 0.9rem; }
.flash--success { background: var(--color-success-soft); color: var(--color-success); }
.flash--error { background: var(--color-danger-soft); color: var(--color-danger); }

.token-reveal { background: var(--color-warning-soft); border: 1px solid var(--color-warning); padding: var(--space-3); border-radius: var(--radius-md); font-family: ui-monospace, monospace; word-break: break-all; }
.placement-block { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); margin-bottom: var(--space-2); }

/* ---- Stat cards (dashboards) ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.stat-card { background: var(--color-surface-raised); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.15s ease; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-card__label { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 2px; }

/* ---- Auth shell (login/register pages, admin + advertiser) ---- */
.auth-shell {
    max-width: 420px;
    margin: var(--space-6) auto;
}
.auth-shell .card { margin-bottom: 0; }
.auth-shell__logo { display: flex; justify-content: center; margin-bottom: var(--space-4); }
.auth-shell h1 { text-align: center; font-size: 1.4rem; }
.auth-shell__footer { text-align: center; margin-top: var(--space-3); font-size: 0.88rem; color: var(--color-text-muted); }

/* ---- Empty states ---- */
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); color: var(--color-text-muted); }
.empty-state svg { color: var(--color-border); margin-bottom: var(--space-3); }

/* ---- Modal (native <dialog>, shared across admin pages) ---- */
dialog.modal {
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    width: calc(100% - var(--space-4) * 2);
    max-width: 560px;
    background: var(--color-surface-raised);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
}
dialog.modal::backdrop { background: rgba(23, 23, 31, 0.5); }
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.modal__header h2 { margin: 0; font-size: 1.05rem; }
.modal__close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0 var(--space-1);
}
.modal__close:hover { color: var(--color-text); }
.modal__body { padding: var(--space-4); max-height: 70vh; overflow-y: auto; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
@media (max-width: 640px) {
    dialog.modal { width: 100%; max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
}

/* ---- Site footer (dark band - hosts the white danielfrank.dk logo).
   flex-shrink:0 + body's flex-column/min-height:100vh (see above) is the
   standard sticky-footer pattern - pins the footer to the viewport bottom
   on short pages instead of it floating right under sparse content. ---- */
.site-footer {
    flex-shrink: 0;
    background: var(--color-secondary);
    padding: var(--space-4);
    text-align: center;
}
.site-footer img { height: 56px; width: auto; opacity: 0.95; }
.site-footer__brand { display: inline-block; line-height: 0; }
.site-footer__links { display: flex; justify-content: center; gap: var(--space-4); margin-bottom: var(--space-3); }
.site-footer__links a { color: rgba(255, 255, 255, 0.85); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.site-footer__links a:hover { color: #fff; text-decoration: underline; }
.site-footer__copyright { color: rgba(255, 255, 255, 0.65); font-size: 0.78rem; margin: var(--space-3) 0 0; }
