/* 
   Shortlink Manager — Anthropic-Inspired Design System
   Warm cream canvas, coral accents, editorial typography
*/

:root {
  --primary: #cc785c;
  --primary-hover: #a9583e;
  --primary-disabled: #e6dfd8;
  --primary-light: #f5ede8;
  --success: #5db872;
  --success-light: #edf7f0;
  --warning: #d4a017;
  --warning-light: #fbf3e0;
  --danger: #c64545;
  --danger-light: #f9ecec;

  --ink: #141413;
  --body: #3d3d3a;
  --body-strong: #252523;
  --muted: #6c6a64;
  --muted-soft: #8e8b82;
  --hairline: #e6dfd8;
  --hairline-soft: #ebe6df;
  --canvas: #faf9f5;
  --surface-soft: #f5f0e8;
  --surface-card: #efe9de;
  --surface-cream-strong: #e8e0d2;
  --surface-dark: #181715;
  --surface-dark-elevated: #252320;
  --surface-dark-soft: #1f1e1b;

  --on-primary: #ffffff;
  --on-dark: #faf9f5;
  --on-dark-soft: #a09d96;

  --font-display: Copernicus, 'Tiempos Headline', 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;
}

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

body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--body);
  background: var(--canvas);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* ============================
   HEADER
   ============================ */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.app-header h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.app-header h2 i {
  color: var(--primary);
  margin-right: 8px;
}
.header-actions { display: flex; gap: 8px; }

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  height: 40px;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--canvas);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--muted-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-light);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--canvas);
  color: var(--muted);
  border: 1px solid var(--hairline);
}
.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: var(--radius-md); }

/* ============================
   CARDS & FORMS
   ============================ */
.card {
  background: var(--surface-card);
  padding: 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.form-group { margin-bottom: 20px; }
.input-icon-wrapper { position: relative; display: flex; align-items: center; }
.input-icon-wrapper i {
  position: absolute;
  left: 12px;
  color: var(--muted-soft);
  font-size: 14px;
  pointer-events: none;
}
.input-icon-wrapper input { padding-left: 36px; }

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all 0.2s;
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}
input::placeholder { color: var(--muted-soft); }

.input-sm { height: 32px; padding: 0 12px 0 36px; font-size: 13px; border-radius: var(--radius-sm); }

.form-actions { display: flex; gap: 12px; margin-top: 32px; }
.form-actions .btn { flex: 1; }

/* ============================
   SUMMARY CARDS (Stats Grid)
   ============================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface-card);
  padding: 20px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.stat-info div:first-child { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-info div:last-child { font-family: var(--font-display); font-size: 28px; font-weight: 400; color: var(--ink); line-height: 1.2; letter-spacing: -0.02em; }

/* ============================
   MOBILE NAVIGATION (Bottom Bar)
   ============================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(250, 249, 245, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  padding: 8px 16px 24px;
  justify-content: space-around;
  z-index: 900;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item i { font-size: 20px; }
.nav-item.active { color: var(--primary); }

/* ============================
   TABLE
   ============================ */
.table-wrapper {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface-card);
  padding: 12px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
}
tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
  background: var(--canvas);
  color: var(--body-strong);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-soft); }

code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-soft);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-weight: 500;
  height: 32px;
  display: inline-flex;
  align-items: center;
}

/* ============================
   BADGES & STATUS
   ============================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: var(--success-light); color: #1a6e3a; }
.badge-danger { background: var(--danger-light); color: #9b2c2c; }
.badge-admin { background: var(--warning-light); color: #8a6d1a; }
.badge-staff { background: var(--surface-soft); color: var(--muted); }
.click-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 11px;
  height: 32px;
  transition: all 0.2s;
}
.click-badge:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Bulk Action Bar */
.bulk-action-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.bulk-action-bar.show { transform: translateX(-50%) translateY(0); }
.bulk-count { font-weight: 500; font-size: 14px; color: var(--on-dark-soft); }

.status-msg, .alert {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-msg, .alert-success {
  background: var(--success-light);
  color: #1a6e3a;
  border-left: 4px solid var(--success);
}

.alert-error {
  background: var(--danger-light);
  color: #9b2c2c;
  border-left: 4px solid var(--danger);
}

.warning-box {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--warning-light);
  border: 1px solid #f0d78a;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 13.5px;
}
.warning-box i { color: var(--warning); font-size: 18px; margin-top: 2px; }
.warning-text strong { color: var(--body-strong); }

/* ============================
   QR & ACTIONS
   ============================ */
.qr-section { display: flex; align-items: center; gap: 12px; }
.qr-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  cursor: pointer;
  padding: 2px;
  background: var(--canvas);
  transition: transform 0.2s;
}
.qr-thumb:hover { transform: scale(1.1); }
.action-group { display: flex; gap: 6px; }

/* ============================
   LOGIN PAGE
   ============================ */
.login-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface-soft);
  padding: 20px;
}
.login-box {
  background: var(--surface-card);
  padding: 48px 40px;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 420px;
}
.login-box h2 {
  text-align: center;
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.login-box .btn { width: 100%; margin-top: 8px; height: 44px; font-size: 15px; }
.login-error {
  text-align: center;
  padding: 12px;
  margin-bottom: 24px;
  color: #9b2c2c;
  background: var(--danger-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(198, 69, 69, 0.1);
}

/* ============================
   MODAL
   ============================ */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 20, 19, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}
.modal.show { display: flex; opacity: 1; }
.modal-content {
  background: var(--surface-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.show .modal-content { transform: translateY(0); }
.modal-handle {
  width: 40px;
  height: 5px;
  background: var(--hairline);
  border-radius: 10px;
  margin: 0 auto 20px;
}
.modal-qr-preview {
  width: 140px;
  height: 140px;
  display: block;
  margin: 0 auto 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  padding: 8px;
}
.download-options { display: grid; grid-template-columns: 1fr; gap: 12px; }
.dl-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--ink);
  transition: all 0.2s;
}
.dl-option:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateX(4px);
}
.dl-option i { font-size: 20px; width: 24px; text-align: center; }
.dl-option strong { display: block; font-size: 15px; }
.dl-option small { color: var(--muted); font-size: 12px; }

#lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 20, 19, 0.95);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#lightbox img { max-width: 85%; max-height: 85%; border-radius: var(--radius-xl); }

/* ============================
   UTILITIES
   ============================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--muted); }
.mobile-flex-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toggle-inline { display: none; }

/* ============================
   RESPONSIVE
   ============================ */

@media (min-width: 768px) {
  .flex-row-desktop { flex-direction: row; }
  .modal { align-items: center; }
  .modal-content { border-radius: var(--radius-lg); transform: scale(0.9); }
  .modal.show .modal-content { transform: scale(1); }
  .modal-handle { display: none; }
  .download-options { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .container { padding: 16px 16px 100px; }
  .app-header { margin-bottom: 16px; }
  .app-header h2 { font-family: var(--font-display); font-size: 28px; }
  .header-actions { display: none; }
  .bottom-nav { display: flex; }

  .card { padding: 16px; }
  .card form { gap: 10px; }

  .table-wrapper { background: transparent; border: none; box-shadow: none; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }

  tbody tr {
    background: var(--canvas);
    margin-bottom: 16px;
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--hairline);
  }

  tbody td {
    padding: 8px 0;
    border-bottom: none;
  }

  tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
  }

  tbody td:first-child::before { display: none; }

  .toggle-col { display: none !important; }
  .toggle-inline { display: inline-flex; }

  .qr-section { flex-direction: column; align-items: stretch; text-align: center; }
  .qr-thumb { width: 80px; height: 80px; margin: 0 auto; }

  .action-group { margin-top: 8px; }
  .action-group .btn-icon { flex: 1; height: 48px; font-size: 16px; }
  
  .form-actions { flex-direction: column; gap: 12px; }
  .form-actions .btn { width: 100%; flex: none; }

  .btn {
    height: 52px;
    font-size: 16px;
    width: 100%;
    font-weight: 500;
  }
  .btn-sm {
    height: 44px;
    font-size: 14px;
    width: auto;
  }
  .input-sm {
    height: 48px;
    font-size: 15px;
    padding-left: 40px !important;
  }
  .btn-lg {
    height: 60px;
    font-size: 18px;
    font-weight: 600;
    width: 100%;
  }
}
