/* ==========================================================================
   URL Encrypter — house theme
   A hand-built layer on top of Bootstrap 5. The design language: an "ink &
   violet" palette, a soft grid paper texture, chunky rounded cards, and a
   Space-Grotesk display face for headings. Light + dark via [data-theme].
   ========================================================================== */

:root {
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Space Grotesk", var(--font-sans);

    /* Brand */
    --violet: #7c3aed;
    --violet-600: #6d28d9;
    --violet-050: #f3efff;
    --coral: #fb7185;
    --mint: #10b981;
    --amber: #f59e0b;

    /* Light theme surfaces */
    --bg: #f6f5fb;
    --bg-grid: rgba(124, 58, 237, .05);
    --surface: #ffffff;
    --surface-2: #faf9ff;
    --border: #e8e6f2;
    --text: #1c1a2e;
    --text-soft: #625d7a;
    --text-faint: #9591ac;

    --shadow-sm: 0 1px 2px rgba(28, 26, 46, .06);
    --shadow: 0 10px 30px -12px rgba(80, 63, 156, .25);
    --shadow-lg: 0 24px 60px -18px rgba(80, 63, 156, .35);

    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;

    --sidebar-w: 264px;
}

[data-theme="dark"] {
    --bg: #0e0c1a;
    --bg-grid: rgba(148, 130, 255, .06);
    --surface: #171426;
    --surface-2: #1e1a30;
    --border: #2b2740;
    --text: #ece9f6;
    --text-soft: #a9a3c4;
    --text-faint: #726c8f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 12px 34px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, .7);
    --violet-050: #201a3a;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

h1, h2, h3, h4, .display {
    font-family: var(--font-display);
    letter-spacing: -.02em;
    color: var(--text);
}

a { color: var(--violet-600); text-decoration: none; }
a:hover { color: var(--violet); }

/* ---- Brand mark --------------------------------------------------------- */
.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
}
.brand__glyph {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--violet), var(--coral));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.brand small { color: var(--text-faint); font-weight: 500; }

/* ==========================================================================
   App shell (sidebar + main)
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.4rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar__head { padding: .2rem .5rem 1.4rem; }
.sidebar__nav { display: flex; flex-direction: column; gap: .18rem; flex: 1; }
.sidebar__label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
    color: var(--text-faint); margin: 1rem .8rem .4rem; font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .62rem .8rem; border-radius: var(--radius-sm);
    color: var(--text-soft); font-weight: 500;
    transition: background .15s, color .15s, transform .15s;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 19px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(2px); }
.nav-item.is-active {
    background: linear-gradient(120deg, var(--violet-050), transparent);
    color: var(--violet-600);
    box-shadow: inset 3px 0 0 var(--violet);
}
[data-theme="dark"] .nav-item.is-active { color: #c4b5fd; }

.sidebar__foot {
    border-top: 1px solid var(--border);
    padding-top: 1rem; margin-top: 1rem;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.6rem;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-size: 1.25rem; font-weight: 600; margin: 0; }
.topbar__spacer { flex: 1; }

.app-content { padding: 1.8rem 1.6rem 3rem; max-width: 1180px; width: 100%; }

/* ---- Search box --------------------------------------------------------- */
.searchbox {
    display: flex; align-items: center; gap: .5rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: .4rem .9rem; min-width: 220px;
}
.searchbox input {
    border: 0; background: transparent; color: var(--text);
    outline: none; width: 100%; font-size: .9rem;
}
.searchbox svg { width: 16px; color: var(--text-faint); }

/* ---- Icon button / theme toggle ---------------------------------------- */
.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center;
    border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-soft); cursor: pointer;
    transition: .15s;
}
.icon-btn:hover { color: var(--violet-600); border-color: var(--violet); }

/* ---- Profile chip ------------------------------------------------------- */
.profile-chip {
    display: flex; align-items: center; gap: .6rem;
    padding: .35rem .5rem .35rem .35rem; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; color: #fff; font-weight: 700;
    background: linear-gradient(135deg, var(--violet), var(--violet-600));
    font-size: .85rem;
}

/* ==========================================================================
   Cards, stats, tables
   ========================================================================== */
.card-x {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 1.4rem;
}
.card-x + .card-x { margin-top: 1.2rem; }
.card-x__title { font-size: 1.05rem; font-weight: 600; margin: 0 0 .2rem; }
.card-x__sub { color: var(--text-soft); font-size: .88rem; margin: 0; }

.stat-grid {
    display: grid; gap: 1.1rem;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.2rem 1.3rem; position: relative;
    overflow: hidden; box-shadow: var(--shadow-sm);
    transition: transform .18s, box-shadow .18s;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat__label { color: var(--text-soft); font-size: .82rem; font-weight: 500; }
.stat__value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; margin-top: .25rem; }
.stat__icon {
    position: absolute; top: 1.1rem; right: 1.1rem;
    width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
}
.stat__icon svg { width: 20px; height: 20px; }
.stat--violet .stat__icon { background: var(--violet-050); color: var(--violet-600); }
.stat--mint   .stat__icon { background: color-mix(in srgb, var(--mint) 16%, transparent); color: var(--mint); }
.stat--coral  .stat__icon { background: color-mix(in srgb, var(--coral) 16%, transparent); color: var(--coral); }
.stat--amber  .stat__icon { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }

.table-x { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-x th {
    text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-faint); font-weight: 600; padding: .6rem .8rem; border-bottom: 1px solid var(--border);
}
.table-x td { padding: .85rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-x tr:last-child td { border-bottom: 0; }
.table-x tr:hover td { background: var(--surface-2); }

.short-link {
    font-family: var(--font-display); font-weight: 600; color: var(--violet-600);
    display: inline-flex; align-items: center; gap: .35rem;
}
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Badges ------------------------------------------------------------- */
.badge-x {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .72rem; font-weight: 600; padding: .22rem .6rem; border-radius: 999px;
    border: 1px solid transparent;
}
.badge-active   { background: color-mix(in srgb, var(--mint) 14%, transparent); color: var(--mint); }
.badge-expired  { background: color-mix(in srgb, var(--coral) 14%, transparent); color: var(--coral); }
.badge-archived { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }
.badge-lock     { background: var(--violet-050); color: var(--violet-600); }

/* ==========================================================================
   Buttons & forms
   ========================================================================== */
.btn-x {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font-family: var(--font-sans); font-weight: 600; font-size: .92rem;
    padding: .62rem 1.1rem; border-radius: 12px; border: 1px solid transparent;
    cursor: pointer; transition: .16s; text-decoration: none; line-height: 1;
}
.btn-x svg { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(120deg, var(--violet), var(--violet-600)); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(1.06); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--violet); color: var(--violet-600); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--coral) 50%, transparent); color: var(--coral); }
.btn-danger:hover { background: var(--coral); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .42rem .75rem; font-size: .82rem; border-radius: 10px; }

.field { margin-bottom: 1.05rem; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .4rem; }
.field .hint { color: var(--text-faint); font-size: .78rem; margin-top: .35rem; }
.input, .textarea, .select {
    width: 100%; padding: .7rem .9rem; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: .94rem; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none; border-color: var(--violet);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--violet) 16%, transparent);
    background: var(--surface);
}
.textarea { min-height: 92px; resize: vertical; }
.input.is-invalid, .textarea.is-invalid { border-color: var(--coral); }
.field-error { color: var(--coral); font-size: .78rem; margin-top: .35rem; }

.input-affix { display: flex; align-items: stretch; }
.input-affix .affix {
    display: inline-flex; align-items: center; padding: 0 .85rem;
    background: var(--violet-050); border: 1px solid var(--border); border-right: 0;
    border-radius: 12px 0 0 12px; color: var(--violet-600); font-weight: 600; font-size: .86rem;
}
.input-affix .input { border-radius: 0 12px 12px 0; }

.checkbox { display: flex; align-items: flex-start; gap: .6rem; }
.checkbox input { margin-top: .2rem; width: 18px; height: 18px; accent-color: var(--violet); }
.checkbox .checkbox__body small { color: var(--text-faint); display: block; }

.locked-feature { position: relative; }
.locked-feature::after {
    content: "PRO"; position: absolute; top: 0; right: 0;
    font-size: .62rem; font-weight: 700; letter-spacing: .05em;
    background: var(--amber); color: #3b2a00; padding: .1rem .4rem; border-radius: 6px;
}

/* ==========================================================================
   Alerts / flash
   ========================================================================== */
.alert-x {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1.2rem;
    border: 1px solid var(--border); font-size: .9rem; font-weight: 500;
}
.alert-x svg { width: 18px; flex: 0 0 18px; margin-top: 2px; }
.alert-success { background: color-mix(in srgb, var(--mint) 12%, transparent); border-color: color-mix(in srgb, var(--mint) 40%, transparent); color: var(--mint); }
.alert-error   { background: color-mix(in srgb, var(--coral) 12%, transparent); border-color: color-mix(in srgb, var(--coral) 40%, transparent); color: var(--coral); }
.alert-info    { background: var(--violet-050); border-color: color-mix(in srgb, var(--violet) 35%, transparent); color: var(--violet-600); }

/* ---- Copy button on links ---------------------------------------------- */
.copy-btn { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; padding: 2px; }
.copy-btn:hover { color: var(--violet-600); }
.copy-btn svg { width: 15px; height: 15px; }

/* ---- Pagination --------------------------------------------------------- */
.pager { display: flex; gap: .4rem; align-items: center; margin-top: 1.3rem; }
.pager a, .pager span {
    padding: .45rem .8rem; border-radius: 10px; border: 1px solid var(--border);
    color: var(--text-soft); font-size: .85rem; font-weight: 500;
}
.pager a:hover { border-color: var(--violet); color: var(--violet-600); }
.pager .is-current { background: var(--violet); color: #fff; border-color: var(--violet); }
.pager .is-disabled { opacity: .5; pointer-events: none; }

/* ---- Empty state -------------------------------------------------------- */
.empty {
    text-align: center; padding: 3rem 1rem; color: var(--text-soft);
}
.empty__glyph {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 1rem;
    display: grid; place-items: center; background: var(--violet-050); color: var(--violet-600);
}

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-aside {
    background: linear-gradient(150deg, var(--violet-600), #3b1d8f 60%, #1e1147);
    color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-aside::before {
    content: ""; position: absolute; inset: 0;
    background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,.14), transparent 40%),
                      radial-gradient(circle at 80% 70%, rgba(251,113,133,.25), transparent 45%);
}
.auth-aside > * { position: relative; }
.auth-aside h2 { color: #fff; font-size: 2rem; line-height: 1.2; }
.auth-aside p { color: rgba(255,255,255,.82); }
.auth-quote { border-left: 3px solid rgba(255,255,255,.4); padding-left: 1rem; font-style: italic; }
.auth-feature { display: flex; gap: .7rem; align-items: center; margin: .6rem 0; color: rgba(255,255,255,.9); }
.auth-feature svg { width: 20px; }

.auth-panel { display: grid; place-items: center; padding: 2rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: .3rem; }
.auth-card .lead { color: var(--text-soft); margin-bottom: 1.6rem; }
.auth-alt { text-align: center; margin-top: 1.4rem; color: var(--text-soft); font-size: .9rem; }

@media (max-width: 860px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* ==========================================================================
   Public landing
   ========================================================================== */
.landing-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.2rem 2rem; max-width: 1160px; margin: 0 auto;
}
.landing-hero { max-width: 1160px; margin: 0 auto; padding: 3rem 2rem 2rem; text-align: center; }
.landing-hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; }
.landing-hero .grad { background: linear-gradient(120deg, var(--violet), var(--coral)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing-hero p.lead { font-size: 1.15rem; color: var(--text-soft); max-width: 620px; margin: 1rem auto 2rem; }
.pill-row { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.4rem; }
.pill { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .4rem .9rem; font-size: .82rem; color: var(--text-soft); box-shadow: var(--shadow-sm); }

.feature-grid { max-width: 1160px; margin: 2rem auto; padding: 0 2rem; display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow-sm); }
.feature__ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--violet-050); color: var(--violet-600); margin-bottom: .9rem; }

.plan-grid { max-width: 1160px; margin: 2.5rem auto; padding: 0 2rem; display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.plan { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.plan.is-featured { border-color: var(--violet); box-shadow: var(--shadow); transform: translateY(-4px); }
.plan__price { font-family: var(--font-display); font-size: 2rem; font-weight: 700; margin: .4rem 0; }
.plan__price small { font-size: .85rem; color: var(--text-faint); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 1rem 0; flex: 1; }
.plan li { padding: .35rem 0; color: var(--text-soft); font-size: .9rem; display: flex; gap: .5rem; }
.plan li svg { width: 16px; color: var(--mint); flex: 0 0 16px; }

.landing-foot { text-align: center; padding: 2.5rem; color: var(--text-faint); border-top: 1px solid var(--border); margin-top: 2rem; }

/* ==========================================================================
   Redirect gate pages
   ========================================================================== */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.gate-card {
    width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 2.4rem; box-shadow: var(--shadow-lg); text-align: center;
}
.gate-card .gate-glyph {
    width: 66px; height: 66px; border-radius: 20px; margin: 0 auto 1.2rem; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--violet), var(--coral)); color: #fff;
}
.gate-card h1 { font-size: 1.5rem; }

/* ==========================================================================
   Utilities
   ========================================================================== */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.stack-sm > * + * { margin-top: .8rem; }
.mt-2x { margin-top: 1.6rem; }
.grid-2 { display: grid; gap: 1.2rem; grid-template-columns: 1fr 1fr; }
.grid-form { display: grid; gap: 0 1.1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) {
    .grid-2, .grid-form { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
    .app-content { padding: 1.2rem; }
    .searchbox { display: none; }
}
.menu-toggle { display: none; }
@media (max-width: 720px) { .menu-toggle { display: grid; } }

/* Dropdown */
.dropdown-x { position: relative; }
.dropdown-x__menu {
    position: absolute; right: 0; top: calc(100% + .5rem); min-width: 200px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: .5rem; display: none; z-index: 40;
}
.dropdown-x__menu.is-open { display: block; }
.dropdown-x__menu a, .dropdown-x__menu button {
    display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
    padding: .55rem .7rem; border-radius: 9px; border: 0; background: transparent;
    color: var(--text); font-size: .9rem; cursor: pointer;
}
.dropdown-x__menu a:hover, .dropdown-x__menu button:hover { background: var(--surface-2); color: var(--violet-600); }
.dropdown-x__divider { height: 1px; background: var(--border); margin: .4rem 0; }
