/* ============================================================================
   gj.al — Gjirafa URL Shortener
   Standalone stylesheet (Bootstrap is no longer loaded). Brand colours come from the
   Gjirafa paw: #F48225 / #D37A1A / #F9A01E / #F7E32B.
   ========================================================================== */

:root {
    --brand: #f48225;
    --brand-strong: #d9691a;
    --brand-soft: #fff4ea;
    --brand-ring: rgba(244, 130, 37, 0.28);

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-sunken: #f9fafb;
    --text: #1d2125;
    --text-2: #4b535c;
    --muted: #6b737c;
    --border: #e3e6ea;
    --border-strong: #cfd4da;

    --ok: #1a7f4b;
    --ok-soft: #ecf7f0;
    --danger: #c43b31;
    --danger-soft: #fdf0ef;

    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);

    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }

a { color: #b95512; text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Top bar --------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand__logo { height: 22px; width: auto; display: block; }
.brand__product {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    padding-left: 10px;
    border-left: 1px solid var(--border);
    line-height: 20px;
}

.nav { display: flex; align-items: stretch; gap: 4px; height: 100%; flex: 1; min-width: 0; }
.nav a {
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--brand); }

.user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user__name { font-size: 13px; color: var(--text-2); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--brand-soft); color: var(--brand-strong);
    font-size: 12px; font-weight: 700;
}

/* Thin progress bar shown while a page / page-section is loading. */
.loadbar {
    position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30;
    background: var(--brand);
    transform-origin: 0 50%;
    transform: scaleX(0);
    opacity: 0;
    pointer-events: none;
}
.loadbar.is-active { opacity: 1; animation: loadbar 2.5s cubic-bezier(.1, .7, .3, 1) forwards; }
.loadbar.is-done { opacity: 0; transform: scaleX(1); transition: opacity .25s ease .1s, transform .15s ease; }
@keyframes loadbar { from { transform: scaleX(0); } to { transform: scaleX(.85); } }

/* ---- Page ------------------------------------------------------------------ */
.page { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 28px 24px 48px; }
.page--narrow { max-width: 760px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.back { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    padding: 16px 24px;
}

/* ---- Cards ----------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card + .card, .card + .grid, .grid + .card { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card__body { padding: 20px; }
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.card__head h2 { font-size: 14px; }
.card__head a { font-size: 13px; }

.grid { display: grid; gap: 16px; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }

/* ---- Forms ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 14px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field__hint { font-size: 12px; color: var(--muted); }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields .field + .field { margin-top: 0; }
.fields .field--wide { grid-column: 1 / -1; }

.input, select.input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder { color: #9aa1a9; }
.input:hover { border-color: #b7bec6; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.input--lg { height: 46px; font-size: 15px; }
.input[readonly] { background: var(--surface-sunken); }

/* "gj.al/" prefix in front of the custom-token input. */
.affix { display: flex; align-items: stretch; }
.affix__text {
    display: inline-flex; align-items: center;
    padding: 0 10px;
    font-family: var(--mono); font-size: 13px; color: var(--muted);
    background: var(--surface-sunken);
    border: 1px solid var(--border-strong); border-right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.affix .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.shorten { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.shorten--custom { grid-template-columns: minmax(0, 1fr) minmax(0, 240px) auto; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px;
    padding: 0 16px;
    font: inherit; font-size: 14px; font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-busy="true"] { cursor: progress; opacity: .7; }
.btn--lg { height: 46px; padding: 0 20px; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-sunken); color: var(--text); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-sunken); color: var(--text); }

/* Busy state: a small spinner replaces nothing, so the button never changes width. */
.btn[aria-busy="true"]::after {
    content: ""; width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Messages ---------------------------------------------------------------- */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid;
}
.alert--error { background: var(--danger-soft); border-color: #f2c9c5; color: #8f2a22; }
.alert--info { background: var(--surface-sunken); border-color: var(--border); color: var(--text-2); }
.alert ul { margin: 0; padding-left: 18px; }
.validation-summary-valid { display: none; }

/* Created link. */
.result {
    margin-top: 16px;
    border: 1px solid #bfe3cd;
    background: var(--ok-soft);
    border-radius: var(--radius);
    padding: 16px 20px;
    animation: rise .2s ease-out;
}
.result__label { font-size: 13px; font-weight: 600; color: var(--ok); margin-bottom: 8px; }
.result__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result__link {
    font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--text);
    word-break: break-all; flex: 1; min-width: 0;
}
.result__dest { margin-top: 8px; font-size: 13px; color: var(--muted); word-break: break-all; }
.result--plain { background: var(--surface-sunken); border-color: var(--border); }
.result--plain .result__label { color: var(--text-2); }
.result--plain .result__link { font-size: 14px; font-weight: 500; }

@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    font-size: 12px; font-weight: 600; color: var(--muted);
    padding: 10px 20px;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 11px 20px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfd; }
.table .num { text-align: right; }
.cell-token { font-family: var(--mono); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cell-url {
    max-width: 380px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text-2);
}
.cell-who { white-space: nowrap; }
.cell-who small { display: block; color: var(--muted); font-size: 12px; }
.cell-date { white-space: nowrap; color: var(--text-2); font-size: 13px; }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }

.tag {
    display: inline-block;
    padding: 1px 7px;
    font-size: 11px; font-weight: 600; letter-spacing: .02em;
    border-radius: 999px;
    color: var(--text-2);
    background: #eef0f3;
    vertical-align: 1px;
}
.tag--brand { color: var(--brand-strong); background: var(--brand-soft); }

/* Copy button inside tables. */
.copy {
    border: 0; background: none; padding: 2px 4px; margin-left: 4px;
    color: var(--muted); cursor: pointer; border-radius: 4px; font: inherit; font-size: 12px;
}
.copy:hover { color: var(--text); background: #eef0f3; }

/* ---- Toolbar (filters / search / window) ---------------------------------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.toolbar .input { height: 34px; font-size: 13px; }
.toolbar__search { flex: 1; min-width: 200px; max-width: 360px; }

.segmented { display: inline-flex; padding: 2px; background: #eef0f3; border-radius: 7px; }
.segmented a {
    padding: 5px 12px; font-size: 13px; font-weight: 500;
    color: var(--text-2); border-radius: 5px;
}
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.pager {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px; color: var(--muted);
}
.pager__links { display: flex; gap: 8px; }
.pager .btn[aria-disabled="true"] { pointer-events: none; opacity: .45; }

/* ---- Stats / bars / chart -------------------------------------------------- */
.stat { padding: 16px 20px; }
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value { font-size: 26px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

.bars { list-style: none; margin: 0; padding: 12px 20px 16px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 4px 12px; padding: 6px 0; font-size: 13px; }
.bars__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bars__track { grid-column: 1 / -1; height: 6px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.bars__fill { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding: 16px 20px 0; }
.chart__bar { flex: 1; min-width: 2px; background: var(--brand); border-radius: 2px 2px 0 0; opacity: .85; }
.chart__bar:hover { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; padding: 6px 20px 14px; font-size: 11px; color: var(--muted); }

.meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; padding: 16px 20px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-all; }

/* ---- Skeletons (async sections) ----------------------------------------- */
.skeleton { padding: 12px 20px 16px; }
.skeleton span {
    display: block; height: 10px; margin: 12px 0; border-radius: 4px;
    background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton span:nth-child(2n) { width: 70%; }
.skeleton span:nth-child(3n) { width: 85%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Region being replaced by an in-place navigation: dim instead of blanking it. */
[data-region][aria-busy="true"] :is(.table-wrap, .empty, .pager, .grid, .chart) { opacity: .55; transition: opacity .15s ease; pointer-events: none; }

/* ---- Gate pages (login / unauthorized / 404) -------------------------------- */
.gate { flex: 1; display: grid; place-items: center; padding: 48px 20px; }
.gate__card { width: 100%; max-width: 380px; text-align: center; padding: 36px 32px; }
.gate__logo { height: 28px; width: auto; margin: 0 auto 24px; display: block; }
.gate h1 { font-size: 19px; margin-bottom: 6px; }
.gate p { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.gate .btn { width: 100%; }

/* SweetAlert2 confirm dialog: match the app. */
.swal2-popup { font-family: var(--font) !important; border-radius: var(--radius) !important; font-size: 14px !important; }
.swal2-title { font-size: 18px !important; }

/* ---- Responsive ------------------------------------------------------------ */
@media (max-width: 860px) {
    .grid--3 { grid-template-columns: 1fr; }
    .user__name { display: none; }
}

@media (max-width: 720px) {
    .topbar__inner { height: auto; flex-wrap: wrap; gap: 0 16px; padding: 10px 16px 0; }
    .nav { order: 3; flex-basis: 100%; height: 42px; overflow-x: auto; scrollbar-width: none; margin: 0 -6px; }
    .nav::-webkit-scrollbar { display: none; }
    .user { margin-left: auto; }
    .page { padding: 20px 16px 40px; }
    .fields, .shorten, .shorten--custom { grid-template-columns: 1fr; }
    .card__body { padding: 16px; }
    .table th, .table td { padding-left: 14px; padding-right: 14px; }
    .hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Native confirm dialog (admin token override). */
dialog.card { padding: 0; border: 1px solid var(--border); color: var(--text); width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(16, 24, 40, 0.35); }
