/* ===== Short Link - Modern Design ===== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --dark: #0f172a;
    --dark-2: #1e293b;
    --text: #1e293b;
    --text-light: #64748b;
    --bg: #f8fafc;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Navbar ---------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(15, 23, 42, .92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 8px 24px rgba(2,6,23,.25);
}
.navbar .brand {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar .brand .logo-dot {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}
.navbar .brand span.grad {
    background: linear-gradient(90deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.navbar nav { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.navbar nav a {
    color: #cbd5e1;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all .18s ease;
}
.navbar nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.navbar nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.navbar .nav-user {
    color: #94a3b8; font-size: 13px; padding: 6px 12px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 20px;
}

/* ---------- Layout ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 36px 20px 70px; }
.container-wide { max-width: 1180px; }

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.05);
    margin-bottom: 22px;
}
.card h2 { margin-bottom: 6px; font-size: 23px; font-weight: 800; letter-spacing: -.4px; }
.card h3 { margin: 20px 0 8px; font-size: 16px; font-weight: 700; }
.card > p.desc { color: var(--text-light); font-size: 14.5px; margin-bottom: 18px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 13.5px; color: var(--dark-2); }
input[type=text], input[type=email], input[type=password], input[type=url],
select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}
input::placeholder { color: #94a3b8; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    margin-top: 18px;
    box-shadow: 0 4px 14px rgba(79,70,229,.28);
    transition: all .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,.38); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-green { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 4px 14px rgba(16,185,129,.28); }
.btn-green:hover { box-shadow: 0 6px 20px rgba(16,185,129,.38); }
.btn-red { background: linear-gradient(135deg, #dc2626, #ef4444); box-shadow: 0 4px 14px rgba(239,68,68,.25); }
.btn-red:hover { box-shadow: 0 6px 20px rgba(239,68,68,.35); }
.btn-gray { background: #64748b; box-shadow: none; }
.btn-gray:hover { background: #475569; }
.btn-sm { padding: 8px 15px; font-size: 13px; margin-top: 0; box-shadow: none; }

/* ---------- Alerts ---------- */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14.5px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
    background: #f8fafc;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-light);
    white-space: nowrap;
}
tr:hover td { background: #fafbfc; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.code {
    font-family: 'Cascadia Code', Consolas, monospace;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12.5px;
    word-break: break-all;
    color: var(--dark-2);
}

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #e0e7ff; color: #3730a3; }

/* ---------- Hero (homepage) ---------- */
.hero {
    text-align: center;
    padding: 72px 20px 56px;
    position: relative;
}
.hero h1 {
    font-size: 46px;
    font-weight: 800;
    letter-spacing: -1.2px;
    margin-bottom: 16px;
    line-height: 1.15;
}
.hero h1 .grad {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    font-size: 17.5px;
    color: var(--text-light);
    max-width: 640px;
    margin: 0 auto 30px;
}
.hero .btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin-top: 44px;
    text-align: left;
}
.feature {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    transition: transform .18s ease, box-shadow .18s ease;
}
.feature:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(15,23,42,.10); }
.feature .f-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eef2ff, #e0f2fe);
    display: flex; align-items: center; justify-content: center;
    font-size: 21px;
    margin-bottom: 14px;
}
.feature h3 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.feature p { font-size: 14px; color: var(--text-light); }

/* ---------- Stat cards (admin) ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 22px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 22px;
}
.stat-card .s-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-light); }
.stat-card .s-value { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }
.stat-card .s-icon  { float: right; font-size: 22px; }

/* ---------- Short result box ---------- */
.result-box {
    background: linear-gradient(135deg, #ecfdf5, #f0fdfa);
    border: 1.5px solid #6ee7b7;
    border-radius: 12px;
    padding: 18px 20px;
    margin: 0 0 20px;
    word-break: break-all;
}
.result-box b { color: #065f46; font-size: 13.5px; text-transform: uppercase; letter-spacing: .05em; }
.copy-btn { float: right; }

/* ---------- Status pills ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 14px;
}
.pill-on  { background: #d1fae5; color: #065f46; }
.pill-off { background: #fee2e2; color: #991b1b; }

/* ---------- API guide ---------- */
pre.api-code {
    background: var(--dark);
    color: #e2e8f0;
    padding: 18px 20px;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.65;
    margin: 12px 0 20px;
    border: 1px solid #1e293b;
}
.api-code .c-green { color: #4ade80; }
.api-code .c-blue  { color: #7dd3fc; }
.api-code .c-amber { color: #fbbf24; }

/* ---------- Auth pages ---------- */
.auth-card { max-width: 430px; margin: 46px auto; }
.auth-card .auth-logo {
    text-align: center;
    margin-bottom: 22px;
}
.auth-card .auth-logo .logo-big {
    width: 56px; height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px;
    margin-bottom: 10px;
    box-shadow: 0 8px 20px rgba(79,70,229,.3);
}
.auth-card .auth-logo h2 { font-size: 24px; }
.auth-card .auth-logo p { color: var(--text-light); font-size: 14px; margin-top: 4px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-light); }

/* ---------- Redirect wait page ---------- */
.wait-page { max-width: 560px; }
.wait-card { text-align: center; padding: 44px 34px; }
.wait-icon { font-size: 52px; margin-bottom: 14px; }
.wait-text { color: var(--text-light); font-size: 15px; margin-bottom: 4px; }
.countdown {
    font-size: 74px;
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1.1;
    margin: 14px 0 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.countdown-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-light);
    margin-bottom: 22px;
}
.wait-dest {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 8px;
}
.wait-dest .dest-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-light);
}
.wait-note {
    margin-top: 18px;
    font-size: 12.5px;
    color: #94a3b8;
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    color: #94a3b8;
    font-size: 13.5px;
    padding: 30px 20px;
    border-top: 1px solid var(--border);
    background: #fff;
}
.footer b { color: var(--dark-2); }

/* ---------- Admin search toolbar ---------- */
.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}
.search-row input { margin: 0; }
.search-row .btn { margin-top: 0; flex-shrink: 0; }
@media (max-width: 480px) {
    .search-row { flex-direction: column; align-items: stretch; }
    .search-row input { max-width: none !important; }
}

/* ---------- Mobile: tables become stacked cards ---------- */
/* Tables with class "stack" turn into labeled cards on phones */
@media (max-width: 640px) {
    table.stack, table.stack tbody, table.stack tr, table.stack td {
        display: block;
        width: 100%;
    }
    table.stack tr:first-child { display: none; }        /* hide the header row */
    .table-wrap:has(table.stack) { border: none; }       /* card borders instead */
    table.stack tr {
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 8px 14px;
        background: #fff;
    }
    table.stack td {
        border-bottom: none;
        padding: 7px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        word-break: break-word;
    }
    table.stack td::before {
        content: attr(data-label);
        font-size: 10.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--text-light);
        flex-shrink: 0;
    }
    table.stack td[data-label="Short Link"],
    table.stack td[data-label="API Key"],
    table.stack td[data-label="Original URL"] {
        display: block;
    }
    table.stack td[data-label="Short Link"]::before,
    table.stack td[data-label="API Key"]::before,
    table.stack td[data-label="Original URL"]::before {
        display: block;
        margin-bottom: 3px;
    }
}

/* =====================================================
   RESPONSIVE — TABLETS & PHONES
   ===================================================== */

/* ---------- Large phones / small tablets (<= 820px) ---------- */
@media (max-width: 820px) {

    /* Navbar: stacks into two clean rows — brand row + links row(s) */
    .navbar {
        height: auto;
        flex-direction: column;
        align-items: center;
        padding: 12px 10px 6px;
        gap: 4px;
    }
    .navbar .brand {
        font-size: 18px;
        white-space: nowrap;            /* never break "Short Link" into two lines */
        flex-shrink: 0;
    }
    .navbar .brand .logo-dot { width: 26px; height: 26px; font-size: 13px; }
    .navbar nav {
        width: 100%;
        margin-left: 0;
        justify-content: center;
        flex-wrap: wrap;                /* links may take a second row — all visible */
        overflow: visible;
        gap: 2px 6px;
        padding-bottom: 6px;
    }
    .navbar nav a { padding: 7px 12px; font-size: 13.5px; white-space: nowrap; }
    .navbar .nav-user { white-space: nowrap; }

    /* Layout & cards */
    .container { padding: 22px 12px 50px; }
    .card { padding: 20px 16px; border-radius: 13px; }
    .card h2 { font-size: 19px; }
    .card h3 { font-size: 15px; }
    .card > p.desc { font-size: 14px; }

    /* Forms: 16px stops iOS auto-zoom on focus */
    input[type=text], input[type=email], input[type=password], input[type=url],
    select, textarea { font-size: 16px; padding: 11px 13px; }

    /* Tables: easier touch scrolling */
    .table-wrap { -webkit-overflow-scrolling: touch; }
    table { font-size: 13px; }
    th, td { padding: 9px 10px; }
    .code { font-size: 12px; padding: 2px 6px; }

    /* Hero */
    .hero { padding: 44px 14px 34px; }
    .hero h1 { font-size: 32px; letter-spacing: -0.8px; }
    .hero p { font-size: 15px; }
    .hero .btn-row .btn { padding: 12px 20px; }

    /* Stat cards */
    .stats-grid { gap: 10px; margin-top: 14px; }
    .stat-card { padding: 14px 16px; border-radius: 12px; }
    .stat-card .s-value { font-size: 24px; }
    .stat-card .s-icon  { float: none; display: inline-block; margin-left: 6px; font-size: 18px; }

    /* API guide code blocks */
    pre.api-code { font-size: 12px; padding: 14px 14px; margin: 10px 0 16px; -webkit-overflow-scrolling: touch; }

    /* Wait page */
    .wait-card { padding: 32px 22px; }
    .wait-icon { font-size: 44px; }
    .countdown { font-size: 56px; letter-spacing: -1px; }

    /* Alerts */
    .alert { font-size: 13.5px; padding: 12px 14px; }

    /* Footer */
    .footer { font-size: 12.5px; padding: 22px 14px; }
}

/* ---------- Phones (<= 480px) ---------- */
@media (max-width: 480px) {

    .navbar .brand { font-size: 16.5px; letter-spacing: -.3px; }
    .navbar nav a { padding: 6px 10px; font-size: 13px; }

    .container { padding: 16px 8px 40px; }
    .card { padding: 18px 14px; margin-bottom: 16px; }
    .card h2 { font-size: 18px; }

    /* Hero: big headline stacks, buttons go full width */
    .hero h1 { font-size: 27px; }
    .hero p { font-size: 14.5px; margin-bottom: 22px; }
    .hero .btn-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .hero .btn-row .btn { width: 100%; text-align: center; }

    /* Main form buttons: full width, easier to tap */
    form > .btn:not(.btn-sm) { width: 100%; text-align: center; }

    /* Buttons: bigger tap targets */
    .btn { padding: 12px 18px; font-size: 14px; margin-top: 14px; }

    /* Table cells: let long URLs wrap instead of scrolling far right */
    .card table td { max-width: none !important; }
    td { word-break: break-word; }
    th { font-size: 11px; padding: 8px 9px; }
    td { padding: 8px 9px; }

    /* Inline label + input spacing tighter */
    label { margin: 12px 0 5px; font-size: 13px; }

    /* Result box */
    .result-box { padding: 14px 14px; }
    .result-box .code { display: block; margin-top: 8px; font-size: 13.5px; }
    .result-box .copy-btn { float: none; display: block; width: 100%; margin-top: 10px; }

    /* Stat cards: compact 3-in-a-row grid on phones */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-top: 12px;
    }
    .stat-card {
        padding: 10px 6px;
        text-align: center;
        border-radius: 11px;
    }
    .stat-card .s-icon { float: none; display: block; font-size: 15px; margin: 0 0 2px; }
    .stat-card .s-label { font-size: 9.5px; letter-spacing: 0; }
    .stat-card .s-value { font-size: 20px; margin-top: 2px; }

    /* Pills & badges */
    .pill { font-size: 13px; padding: 7px 14px; }

    /* Auth pages */
    .auth-card { margin: 28px auto; max-width: 100%; }
    .auth-card .auth-logo h2 { font-size: 20px; }
    .auth-card .auth-logo p { font-size: 13px; }

    /* Wait page */
    .wait-card { padding: 26px 16px; }
    .wait-dest { padding: 8px 12px; font-size: 13px; max-width: 100%; overflow: hidden; }

    /* API guide: tighter code blocks */
    pre.api-code { font-size: 11.5px; padding: 12px 12px; border-radius: 10px; }
}

/* ---------- Very small phones (<= 360px) ---------- */
@media (max-width: 360px) {
    .navbar .brand { font-size: 15px; }
    .hero h1 { font-size: 23px; }
    .card h2 { font-size: 17px; }
    pre.api-code { font-size: 11px; }
}
