/* ============================================================
   style.css — URL Shortener Admin Panel
   Design: Clean industrial-monospace with ink-on-paper feel
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Variables ────────────────────────────────────────────── */
:root {
    --bg:         #0f0f11;
    --bg2:        #16161a;
    --bg3:        #1e1e24;
    --border:     #2a2a32;
    --border2:    #383845;
    --text:       #e8e8f0;
    --text2:      #9090a8;
    --text3:      #5c5c70;
    --accent:     #6c63ff;
    --accent2:    #8b83ff;
    --accent-bg:  rgba(108,99,255,.12);
    --green:      #34d399;
    --green-bg:   rgba(52,211,153,.1);
    --red:        #f87171;
    --red-bg:     rgba(248,113,113,.1);
    --amber:      #fbbf24;
    --font-ui:    'DM Sans', system-ui, sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
    --radius:     10px;
    --radius-lg:  16px;
    --shadow:     0 4px 24px rgba(0,0,0,.4);
    --transition: 0.18s ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }
img { max-width: 100%; }

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}
.nav-brand {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: .02em;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.nav-user {
    font-size: .85rem;
    color: var(--text2);
    font-family: var(--font-mono);
}

/* ── Layout ───────────────────────────────────────────────── */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}
.admin-narrow {
    max-width: 700px;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
}
.page-subtitle {
    color: var(--text2);
    font-size: .9rem;
    margin-top: .2rem;
}

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border2); }
.stat-icon { font-size: 1.4rem; }
.stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}
.stat-label {
    font-size: .8rem;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .08em;
}

/* ── Card ─────────────────────────────────────────────────── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Search ───────────────────────────────────────────────── */
.search-box input {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .5rem 1rem;
    border-radius: 8px;
    font-size: .875rem;
    font-family: var(--font-ui);
    width: 240px;
    transition: border-color var(--transition);
}
.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg3);
}
.search-box input::placeholder { color: var(--text3); }

/* ── Table ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th {
    text-align: left;
    padding: .75rem 1rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text3);
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg3); }

.col-num   { color: var(--text3); font-family: var(--font-mono); font-size: .8rem; }
.col-code  { white-space: nowrap; }
.col-title { color: var(--text2); max-width: 160px; }
.col-url   { max-width: 280px; }
.col-clicks { text-align: center; }
.col-date  { white-space: nowrap; color: var(--text2); font-size: .82rem; }
.col-actions { white-space: nowrap; }

.url-truncate {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text2);
    font-size: .82rem;
    max-width: 280px;
}

.shortlink-badge {
    display: inline-block;
    background: var(--accent-bg);
    color: var(--accent2);
    font-family: var(--font-mono);
    font-size: .82rem;
    padding: .2rem .6rem;
    border-radius: 6px;
    border: 1px solid rgba(108,99,255,.3);
    text-decoration: none;
    transition: background var(--transition);
}
.shortlink-badge:hover {
    background: rgba(108,99,255,.22);
    text-decoration: none;
    color: var(--accent2);
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    padding: .1rem .3rem;
    border-radius: 4px;
    opacity: .5;
    transition: opacity var(--transition);
    vertical-align: middle;
    margin-left: .2rem;
}
.copy-btn:hover { opacity: 1; }

.click-badge {
    display: inline-block;
    background: var(--green-bg);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: .8rem;
    font-weight: 600;
    padding: .15rem .6rem;
    border-radius: 99px;
    min-width: 40px;
    text-align: center;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text2);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.2rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--font-ui);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-full { width: 100%; }

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

.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border-color: var(--border2);
}
.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
    border-color: var(--border2);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border-color: rgba(248,113,113,.25);
}
.btn-danger:hover {
    background: rgba(248,113,113,.2);
    color: var(--red);
}

.btn-ghost {
    background: transparent;
    color: var(--text2);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg3);
    color: var(--text);
}

.btn-sm {
    padding: .35rem .8rem;
    font-size: .8rem;
    border-radius: 6px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: .9rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.2rem;
    font-size: .875rem;
    line-height: 1.5;
}
.alert-error {
    background: var(--red-bg);
    border: 1px solid rgba(248,113,113,.3);
    color: var(--red);
}
.alert-success {
    background: var(--green-bg);
    border: 1px solid rgba(52,211,153,.3);
    color: var(--green);
}
.muted { color: var(--text3); }

/* ── Forms ────────────────────────────────────────────────── */
.form-main { padding: 1.5rem; }
.form-group {
    margin-bottom: 1.4rem;
}
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .5rem;
}
.required { color: var(--red); }
.optional { color: var(--text3); font-weight: 400; }
.form-hint {
    display: block;
    font-size: .78rem;
    color: var(--text3);
    margin-top: .4rem;
}
.form-meta {
    font-size: .8rem;
    color: var(--text3);
    font-family: var(--font-mono);
    margin-bottom: 1.5rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .65rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
    font-family: var(--font-ui);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,99,255,.15);
}
input::placeholder,
textarea::placeholder { color: var(--text3); }

.input-prefix-wrapper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-prefix-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,99,255,.15);
}
.input-prefix {
    display: flex;
    align-items: center;
    padding: 0 .9rem;
    background: var(--bg3);
    color: var(--text3);
    font-family: var(--font-mono);
    font-size: .8rem;
    border-right: 1px solid var(--border);
    white-space: nowrap;
}
.input-prefix-wrapper input {
    border: none;
    border-radius: 0;
    flex: 1;
    box-shadow: none !important;
}
.input-prefix-wrapper input:focus { outline: none; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding-top: .5rem;
    border-top: 1px solid var(--border);
    margin-top: 1.5rem;
}

/* ── Preview Card ─────────────────────────────────────────── */
.preview-card { padding: 1.25rem 1.5rem; }
.preview-card h3 {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text3);
    margin-bottom: .75rem;
}
.preview-url {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.preview-short {
    font-family: var(--font-mono);
    font-size: .9rem;
    color: var(--accent2);
    background: var(--accent-bg);
    padding: .3rem .75rem;
    border-radius: 6px;
}
.preview-arrow { color: var(--text3); }
.preview-target {
    font-family: var(--font-mono);
    font-size: .82rem;
    color: var(--text2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 340px;
}

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}
.login-wrapper {
    width: 100%;
    max-width: 400px;
}
.login-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.login-logo {
    font-size: 2.5rem;
    margin-bottom: .75rem;
}
.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: .25rem;
}
.login-subtitle {
    color: var(--text3);
    font-size: .85rem;
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-family: var(--font-mono);
}
.login-form { text-align: left; }
.login-form .form-group { margin-bottom: 1.1rem; }
.login-form .btn-primary { margin-top: .5rem; }

/* ── Landing Page ─────────────────────────────────────────── */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}
.landing-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    text-align: center;
    max-width: 420px;
    box-shadow: var(--shadow);
}
.landing-icon { font-size: 3rem; margin-bottom: 1rem; }
.landing-card h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: .5rem;
}
.landing-card p {
    color: var(--text2);
    margin-bottom: 2rem;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg3);
    color: var(--green);
    border: 1px solid rgba(52,211,153,.3);
    padding: .75rem 1.25rem;
    border-radius: 8px;
    font-size: .875rem;
    font-family: var(--font-mono);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    z-index: 9999;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .admin-container { padding: 1.25rem 1rem 3rem; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn { width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .search-box input { width: 100%; }
    .card-header { flex-direction: column; align-items: stretch; }
    .data-table { min-width: 700px; }
    .col-url { display: none; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card, .landing-card { padding: 2rem 1.25rem; }
}
