/* ===================================================================
   Link Shortener Admin — Design System
   Dark glassmorphism with vibrant accents
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- Design Tokens --- */
:root {
  --bg-deep: #0a0e1a;
  --bg-surface: rgba(255, 255, 255, 0.04);
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-hover: rgba(255, 255, 255, 0.09);
  --bg-input: rgba(255, 255, 255, 0.07);
  --bg-input-focus: rgba(255, 255, 255, 0.12);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(129, 140, 248, 0.6);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #818cf8;

  --accent-primary: #818cf8;
  --accent-secondary: #a78bfa;
  --accent-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c084fc 100%);
  --accent-glow: 0 0 20px rgba(129, 140, 248, 0.3);

  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;

  --glass-blur: blur(20px);
  --glass-border: 1px solid var(--border-subtle);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated gradient background orbs */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 600px;
  height: 600px;
  background: #818cf8;
  top: -200px;
  right: -100px;
  animation: orbFloat 20s ease-in-out infinite;
}
body::after {
  width: 500px;
  height: 500px;
  background: #c084fc;
  bottom: -150px;
  left: -100px;
  animation: orbFloat 25s ease-in-out infinite reverse;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* --- Layout --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  margin-bottom: 24px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: rgba(255,255,255,0.1);
  padding: 4px;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-domain {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', monospace;
  border: var(--glass-border);
}

/* --- Cards / Glass Panels --- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: border-color var(--transition-base);
}

.glass-card:hover {
  border-color: var(--border-medium);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 1.2rem;
}

/* --- Quick Create Section --- */
.quick-create {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.quick-create .field {
  flex: 1;
  min-width: 180px;
}

.quick-create .field-slug {
  flex: 0.6;
  min-width: 140px;
}

.quick-create .field-publisher {
  flex: 0.6;
  min-width: 160px;
}

.slug-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'Inter', monospace;
}

.slug-preview span {
  color: var(--text-accent);
}

/* --- Form Elements --- */
label {
  display: block;
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

input:focus, select:focus, textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

select option {
  background: #1e293b;
  color: var(--text-primary);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 12px rgba(129, 140, 248, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(129, 140, 248, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-icon {
  padding: 7px 10px;
  font-size: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.25);
  border-color: rgba(248, 113, 113, 0.4);
}

.btn-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.btn-success:hover {
  background: rgba(52, 211, 153, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* --- Search Bar --- */
.search-bar {
  position: relative;
  margin-bottom: 16px;
}

.search-bar input {
  padding-left: 40px;
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* --- Table --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tbody td {
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

.cell-slug {
  font-family: 'Inter', monospace;
  font-weight: 500;
  color: var(--text-accent);
}

.cell-destination {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

/* Editable cells */
.editable {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}

.editable:hover {
  background: var(--bg-input);
  border-color: var(--border-subtle);
}

.edit-input {
  padding: 6px 10px;
  font-size: 0.85rem;
  background: var(--bg-input-focus);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  width: 100%;
  min-width: 100px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

/* --- Stats Section --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  transition: all var(--transition-base);
}

.stat-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.tab {
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(129, 140, 248, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* --- Stats sub-tables --- */
.geo-table-wrapper {
  max-height: 240px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
}

.geo-table-wrapper table {
  font-size: 0.82rem;
}

.geo-table-wrapper td, .geo-table-wrapper th {
  padding: 8px 12px;
}

.flag {
  font-size: 1.1rem;
  margin-right: 6px;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Modal / Dialog --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #1e293b;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
  animation: slideUp 0.3s ease;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-text {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

/* QR Modal specifics */
.qr-display {
  text-align: center;
  padding: 20px 0;
}

.qr-display canvas {
  border-radius: var(--radius-md);
  border: 3px solid rgba(255,255,255,0.1);
}

.qr-url {
  font-size: 0.8rem;
  color: var(--text-accent);
  margin-bottom: 16px;
  word-break: break-all;
  font-family: 'Inter', monospace;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 3.5s forwards;
  backdrop-filter: blur(12px);
}

.toast-success {
  background: rgba(16, 185, 129, 0.9);
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.toast-error {
  background: rgba(220, 38, 38, 0.9);
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.toast-info {
  background: rgba(99, 102, 241, 0.9);
  border: 1px solid rgba(129, 140, 248, 0.4);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.4s ease forwards;
}

/* --- Row animation stagger --- */
tbody tr {
  animation: fadeInUp 0.3s ease backwards;
}

tbody tr:nth-child(1) { animation-delay: 0.02s; }
tbody tr:nth-child(2) { animation-delay: 0.04s; }
tbody tr:nth-child(3) { animation-delay: 0.06s; }
tbody tr:nth-child(4) { animation-delay: 0.08s; }
tbody tr:nth-child(5) { animation-delay: 0.10s; }
tbody tr:nth-child(6) { animation-delay: 0.12s; }
tbody tr:nth-child(7) { animation-delay: 0.14s; }
tbody tr:nth-child(8) { animation-delay: 0.16s; }
tbody tr:nth-child(9) { animation-delay: 0.18s; }
tbody tr:nth-child(10) { animation-delay: 0.20s; }

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-container {
    padding: 12px 10px 40px;
  }

  .header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 16px;
  }

  .header-right {
    width: 100%;
    justify-content: center;
  }

  .quick-create {
    flex-direction: column;
  }

  .quick-create .field,
  .quick-create .field-slug,
  .quick-create .field-publisher {
    min-width: 100%;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .glass-card {
    padding: 16px;
  }

  .cell-destination {
    max-width: 140px;
  }

  .modal-content {
    margin: 12px;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .header-title {
    font-size: 1.2rem;
  }

  table {
    font-size: 0.8rem;
  }

  thead th, tbody td {
    padding: 8px 10px;
  }
}

/* --- Login Screen --- */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: slideUp 0.4s ease;
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
  margin-bottom: 20px;
}

