/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --bg-card:   #1e293b;
  --bg-input:  #0f172a;
  --border:    #334155;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --primary:   #38bdf8;
  --primary-h: #0ea5e9;
  --danger:    #f87171;
  --success:   #4ade80;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: monospace; background: var(--border); padding: 2px 6px; border-radius: 4px; font-size: .9em; }

/* ===== Layout ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}
.logo:hover { text-decoration: none; }

.header-nav { display: flex; gap: .5rem; }

main { flex: 1; padding: 2rem 1rem; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #0f172a; }
.btn-primary:hover { background: var(--primary-h); text-decoration: none; }
.btn-ghost  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card); text-decoration: none; }
.btn-sm { padding: .35rem .8rem; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Hero (index) ===== */
.hero {
  max-width: 680px;
  margin: 4rem auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  text-align: center;
}

.hero-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.shorten-box {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.input-row {
  display: flex;
  gap: .75rem;
}

.url-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.url-input:focus { border-color: var(--primary); }
.url-input::placeholder { color: var(--muted); }

.result-box { display: flex; flex-direction: column; gap: .75rem; }
.result-url-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.result-url { font-size: 1.15rem; font-weight: 700; color: var(--primary); word-break: break-all; }
.result-expires { color: var(--muted); font-size: .85rem; }

.qr-area { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.qr-img { width: 128px; height: 128px; border-radius: 6px; border: 1px solid var(--border); }

.info-list {
  list-style: none;
  color: var(--muted);
  font-size: .9rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  text-align: left;
  width: 100%;
}
.info-list li::before { content: "• "; color: var(--primary); }

/* ===== Auth ===== */
.auth-section {
  display: flex;
  justify-content: center;
  padding-top: 4rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-links { margin-top: 1.25rem; font-size: .88rem; color: var(--muted); text-align: center; }
.divider { margin: 0 .4rem; }

/* ===== Form ===== */
.form-label { display: flex; flex-direction: column; gap: .4rem; font-size: .9rem; font-weight: 500; }
.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--primary); }

/* ===== Preview ===== */
.preview-section { display: flex; justify-content: center; padding-top: 4rem; }
.preview-card {
  max-width: 520px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}
.preview-icon { line-height: 1; }
.preview-title { font-size: 1.3rem; font-weight: 700; }
.preview-subtitle { color: var(--muted); font-size: .9rem; }
.preview-url-box {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  word-break: break-all;
}
.preview-url-text { font-size: .95rem; color: var(--text); }
.preview-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }

/* ===== Error / 404 ===== */
.error-section { display: flex; justify-content: center; padding-top: 5rem; }
.error-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.error-code { font-size: 5rem; font-weight: 900; color: var(--border); line-height: 1; }
.error-title { font-size: 1.5rem; font-weight: 700; }
.error-desc { color: var(--muted); }

/* ===== Utilities ===== */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error-msg { color: var(--danger); font-size: .88rem; }

/* ===== Manage ===== */
.manage-section {
  max-width: 900px;
  margin: 2rem auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.url-prefix-label {
  color: var(--muted);
  font-size: .95rem;
  white-space: nowrap;
  padding: .6rem 0;
}

.form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  cursor: pointer;
}
.form-select:focus { border-color: var(--primary); }

.badge {
  background: var(--border);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.table-wrap { overflow-x: auto; }

.url-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.url-table th {
  text-align: left;
  padding: .6rem .75rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.url-table td {
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.url-table tr:last-child td { border-bottom: none; }
.url-table tr:hover td { background: rgba(255,255,255,.02); }

.td-url { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.status-badge {
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.status-active   { background: rgba(74,222,128,.15); color: var(--success); }
.status-expired  { background: rgba(248,113,113,.15); color: var(--danger); }
.status-inactive { background: var(--border); color: var(--muted); }

.empty-msg { color: var(--muted); font-size: .9rem; text-align: center; padding: 1.5rem 0; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.modal-wide { min-width: 420px; max-width: 540px; width: 90vw; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value  { font-size: 1.6rem; font-weight: 800; color: var(--primary); }

.stats-daily { margin-top: .75rem; }
.stats-daily-title { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.bar {
  width: 100%;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height .2s;
}
.bar-label { font-size: .65rem; color: var(--muted); white-space: nowrap; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .input-row { flex-direction: column; }
  .hero { margin-top: 2rem; }
  .site-header { padding: 0 1rem; }
}
