/* ── Reset & base ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

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

:root {
    --bg:          #f7f6f3;
    --surface:     #ffffff;
    --border:      #e2e0da;
    --border-mid:  #ccc9c0;
    --text:        #1a1916;
    --text-muted:  #7a7670;
    --accent:      #2d6a4f;
    --accent-dark: #1b4332;
    --accent-soft: #d8f3dc;
    --danger:      #c0392b;
    --danger-soft: #fdecea;
    --warn:        #e67e22;
    --warn-soft:   #fef3e2;
    --inactive:    #aaa;
    --radius:      6px;
    --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --font-sans:   'IBM Plex Sans', system-ui, sans-serif;
    --font-mono:   'IBM Plex Mono', 'Fira Code', monospace;
}

html { font-size: 15px; }

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

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

/* ── Nav ───────────────────────────────────────────────────────────── */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -.01em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav-links a {
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active { color: var(--text); text-decoration: none; }

.nav-links form { margin: 0; }

/* ── Main layout ───────────────────────────────────────────────────── */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -.02em;
}

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.create-card {
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.create-card h3 {
    font-size: .85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: .85rem;
}

/* ── Stats ─────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent);
    line-height: 1;
}

.stat-label {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: .35rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 2rem 0 1rem;
}

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-row {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
}

.field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 120px;
}

.field-wide  { flex: 2; min-width: 200px; }
.field-narrow{ flex: 0 0 130px; }
.field-check { flex: 0 0 auto; justify-content: flex-end; padding-bottom: .35rem; }
.field-action,
.field-actions { flex: 0 0 auto; display: flex; gap: .4rem; align-items: center; padding-bottom: .1rem; }

label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.field-check label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    cursor: pointer;
}

input[type="text"],
input[type="url"],
input[type="password"],
select {
    height: 36px;
    padding: 0 .65rem;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}

.slug-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.slug-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}

.slug-prefix {
    padding: 0 .5rem 0 .7rem;
    background: var(--bg);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: .9rem;
    border-right: 1px solid var(--border-mid);
    height: 36px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.slug-input input {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.slug-input input:focus {
    border: none;
    box-shadow: none;
}

/* Login ─────────────────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.login-header h1 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; }
.login-header p { color: var(--text-muted); font-size: .875rem; margin-top: .25rem; }

.login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: 0 .9rem;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-mid);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: transparent;
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { height: 30px; padding: 0 .65rem; font-size: .8rem; }
.btn-full { width: 100%; }

/* ── Table ─────────────────────────────────────────────────────────── */
.redirect-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.redirect-table thead tr {
    border-bottom: 2px solid var(--border);
    background: var(--bg);
}

.redirect-table th {
    padding: .65rem 1rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.redirect-table th.center { text-align: center; }

.redirect-row td {
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.redirect-row:last-child td { border-bottom: none; }
.redirect-row:hover td { background: #fafaf8; }
.redirect-row.inactive td { opacity: .55; }

.redirect-row.editing td {
    background: var(--accent-soft);
    padding: .75rem 1rem;
}

td.center { text-align: center; }
.cell-actions { white-space: nowrap; }
td.cell-slug code {
    font-family: var(--font-mono);
    font-size: .82rem;
    background: var(--bg);
    padding: .15rem .45rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

td.cell-target a {
    display: block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: .82rem;
}

td.cell-target a:hover { color: var(--accent); }

td.cell-clicks {
    font-family: var(--font-mono);
    font-size: .82rem;
}

/* ── Badges ────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .75rem;
    font-weight: 500;
}

.badge-301 { background: var(--warn-soft); color: var(--warn); }
.badge-302 { background: var(--accent-soft); color: var(--accent-dark); }

/* ── Toggle ────────────────────────────────────────────────────────── */
.toggle-btn {
    padding: .15rem .5rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    border: 1.5px solid var(--border-mid);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}

.toggle-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
}

.toggle-btn:hover { opacity: .8; }

/* ── Icons ─────────────────────────────────────────────────────────── */
.check { color: var(--accent); font-weight: 600; }
.dash  { color: var(--border-mid); }

/* ── Flash messages ────────────────────────────────────────────────── */
.flash {
    padding: .65rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.flash-error   { background: var(--danger-soft); color: var(--danger);  border-color: #f5c6cb; }
.flash-success { background: var(--accent-soft); color: var(--accent-dark); border-color: #b7e4c7; }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem !important;
    color: var(--text-muted);
    font-size: .9rem;
}

/* ── Edit form inside table ────────────────────────────────────────── */
.edit-form { padding: .25rem 0; }

/* ── HTMX in-flight indicator ──────────────────────────────────────── */
.htmx-request .btn-primary { opacity: .65; cursor: wait; }
.htmx-settling tr { opacity: .8; }

/* ── Inline utility ────────────────────────────────────────────────── */
.inline { display: inline; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .form-row { flex-direction: column; }
    .field, .field-wide, .field-narrow { width: 100%; flex: unset; }
    td.cell-target a { max-width: 140px; }
}

/* Optional field label hint */
.optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-size: .75rem;
}

/* ── Domain redirect styling ───────────────────────────────────────── */
.redirect-row-domain td {
    background: #fafffe;
}

.redirect-row-domain:hover td {
    background: #f0fdf4;
}

.cell-domain {
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}

.cell-domain code {
    font-family: var(--font-mono);
    font-size: .85rem;
    font-weight: 500;
    color: var(--accent-dark);
    background: var(--accent-soft);
    padding: .15rem .5rem;
    border-radius: 4px;
    border: 1px solid #b7e4c7;
}

.domain-badge {
    font-size: .9rem;
    flex-shrink: 0;
}

/* ── Section headers ───────────────────────────────────────────────── */
.section-desc {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

.section-desc code {
    font-family: var(--font-mono);
    background: var(--bg);
    padding: .1rem .3rem;
    border-radius: 3px;
    border: 1px solid var(--border);
    font-size: .8rem;
}

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -.02em;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.section-header-secondary {
    margin-top: 2.5rem;
}

/* ── Arrow between source and target ──────────────────────────────── */
.field-arrow {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    padding-bottom: .5rem;
}

.arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 36px;
}

/* ── Domain field wider than slug ──────────────────────────────────── */
.field-domain {
    flex: 1.5;
    min-width: 180px;
}

/* ── Primary stat card highlight ───────────────────────────────────── */
.stat-card-primary {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.stat-card-primary .stat-value {
    color: var(--accent-dark);
}

.stat-card-primary .stat-label {
    color: var(--accent);
}

/* ── Secondary add button ──────────────────────────────────────────── */
.btn-secondary {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-secondary:hover {
    background: var(--accent-soft);
}

/* ── Table card spacing ─────────────────────────────────────────────  */
.table-card {
    margin-bottom: 1rem;
    /* Override .card's overflow:hidden on the x-axis so the table can
       scroll horizontally on narrow viewports instead of clipping columns. */
    overflow-x: auto;
}

/* ── www hint badge ─────────────────────────────────────────────────── */
.www-hint {
    font-size: .68rem;
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid #b7e4c7;
    border-radius: 3px;
    padding: .1rem .35rem;
    opacity: .75;
    white-space: nowrap;
}

/* ── TLS certificate status badges ─────────────────────────────────── */
.cell-cert { white-space: nowrap; text-align: center; }

.cert-badge {
    display: inline-block;
    font-size: .72rem;
    font-family: var(--font-mono);
    font-weight: 500;
    padding: .15rem .45rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

.cert-ok {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-color: #b7e4c7;
}

.cert-warning {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: #f9c784;
}

.cert-expired {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #f5c6cb;
}

.cert-none {
    color: var(--border-mid);
}

/* ── Notes ──────────────────────────────────────────────────────────── */
.form-row-notes {
    margin-top: .5rem;
}

.field-notes {
    flex: 1;
    min-width: 0;
}

.cell-notes {
    max-width: 200px;
}

.notes-text {
    display: block;
    font-size: .8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    font-style: italic;
}

.notes-empty {
    color: var(--border-mid);
}

/* ── WHOIS registrar & domain expiry ───────────────────────────────── */
.cell-whois-registrar {
    text-align: center;
    width: 120px;
    max-width: 120px;
}

.whois-registrar {
    display: inline-block;
    font-size: .78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 110px;
    vertical-align: middle;
}

.cell-whois-expiry { white-space: nowrap; text-align: center; }

.whois-badge {
    display: inline-block;
    font-size: .72rem;
    font-family: var(--font-mono);
    font-weight: 500;
    padding: .15rem .45rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

.whois-ok {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-color: #b7e4c7;
}

.whois-warning {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: #f9c784;
}

.whois-expired {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #f5c6cb;
}

.whois-none {
    color: var(--border-mid);
}

/* ── Sortable table headers ─────────────────────────────────────────── */
th[data-sortable] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th[data-sortable]:hover {
    color: var(--text);
}

th[data-sortable]::after {
    content: ' ⇅';
    color: var(--border-mid);
    font-size: .6rem;
    vertical-align: middle;
}

th[data-sortable].sort-asc::after {
    content: ' ↑';
    color: var(--accent);
}

th[data-sortable].sort-desc::after {
    content: ' ↓';
    color: var(--accent);
}

/* ── Azure / Microsoft sign-in button ──────────────────────────────── */
.btn-azure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #d0d0d0;
    border-radius: var(--radius);
    padding: .55rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, border-color .15s, box-shadow .15s;
}

.btn-azure:hover {
    background: #f5f5f5;
    border-color: #a0a0a0;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

.azure-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Login divider ──────────────────────────────────────────────────── */
.login-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .5rem 0;
    color: var(--text-muted);
    font-size: .78rem;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
