/* ============================================================
   Traqr — CSS principale
   Variabili, reset, layout, componenti
   ============================================================ */

:root {
  --primary:    #6366f1;
  --primary-dk: #4f46e5;
  --success:    #10b981;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: system-ui, -apple-system, sans-serif; color: var(--gray-800); background: var(--gray-50); line-height: 1.5; }

/* ---- Layout ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ---- Navbar ---- */
.navbar { background: #fff; border-bottom: 1px solid var(--gray-200); padding: .75rem 1.5rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.navbar-brand { font-weight: 700; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.navbar-menu { display: flex; gap: 1rem; align-items: center; }
.navbar-menu a { color: var(--gray-600); text-decoration: none; font-size: .9rem; }
.navbar-menu a:hover { color: var(--primary); }

/* ---- Auth layout ---- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }
.auth-container { background: #fff; border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-logo { display: block; font-size: 1.5rem; font-weight: 700; color: var(--primary); text-decoration: none; margin-bottom: 1.5rem; text-align: center; }
.auth-footer { margin-top: 1.25rem; text-align: center; font-size: .9rem; color: var(--gray-600); }
.auth-footer a { color: var(--primary); }

/* ---- Flash messages ---- */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin: 1rem 0; font-size: .9rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error   { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef9c3; color: #854d0e; }
.flash-info    { background: #dbeafe; color: #1e40af; }

/* ---- Card ---- */
.card { background: #fff; border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h2 { margin: 0; }
.card-actions { display: flex; gap: .75rem; margin-top: 1rem; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 6px; font-size: .875rem; font-weight: 500; cursor: pointer; text-decoration: none; border: none; transition: background .15s, opacity .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-ghost    { background: var(--gray-200); color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-200); color: var(--gray-800); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-upgrade  { background: #f59e0b; color: #fff; font-weight: 700; }
.btn-full     { width: 100%; justify-content: center; }
.btn-sm       { padding: .3rem .6rem; font-size: .8rem; }
.btn-lg       { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-link     { background: none; border: none; color: var(--gray-600); cursor: pointer; font-size: .9rem; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; color: var(--gray-600); margin-bottom: .4rem; }
.form-group small { display: block; font-size: .78rem; color: var(--gray-400); margin-top: .25rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.form-card { max-width: 640px; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }

input[type=text], input[type=email], input[type=password],
input[type=url], input[type=tel], input[type=number],
input[type=search], input[type=datetime-local], input[type=color],
select, textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--gray-200);
  border-radius: 6px; font-size: .875rem; color: var(--gray-800);
  background: #fff; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.input-lg { font-size: 1rem; padding: .65rem .9rem; }
.input-prefix-group { display: flex; align-items: stretch; }
.input-prefix { background: var(--gray-100); border: 1px solid var(--gray-200); border-right: none; padding: .5rem .75rem; border-radius: 6px 0 0 6px; font-size: .875rem; color: var(--gray-600); white-space: nowrap; display: flex; align-items: center; }
.input-prefix-group input { border-radius: 0 6px 6px 0; }
.select-full { width: 100%; }
.select-sm   { padding: .3rem .5rem; font-size: .8rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .875rem; margin-bottom: .5rem; }
.checkbox-label input { width: auto; }

/* ---- OTP inputs ---- */
.otp-inputs { display: flex; gap: .75rem; justify-content: center; margin: 1.5rem 0; }
.otp-digit  { width: 52px; height: 64px; text-align: center; font-size: 1.75rem; font-weight: 700; border: 2px solid var(--gray-200); border-radius: var(--radius); padding: 0; }
.otp-digit:focus { border-color: var(--primary); }
.otp-timer  { text-align: center; color: var(--gray-400); font-size: .875rem; margin-bottom: 1rem; }
.otp-resend { text-align: center; margin-top: 1rem; }

/* ---- Stats grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card  { background: #fff; border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: var(--shadow); }
.stat-value { font-size: 1.875rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--gray-400); margin-top: .25rem; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--gray-200); font-size: .875rem; }
.table th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); }
.table-compact th, .table-compact td { padding: .4rem .5rem; font-size: .8rem; }
.row-inactive td { opacity: .6; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: var(--gray-100); color: var(--gray-600); }
.badge-expired  { background: #fee2e2; color: #991b1b; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: .25rem; justify-content: center; margin-top: 1.5rem; }
.page-link  { padding: .4rem .75rem; border-radius: 6px; background: var(--gray-200); color: var(--gray-600); text-decoration: none; font-size: .875rem; }
.page-link.active { background: var(--primary); color: #fff; }

/* ---- Misc helpers ---- */
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.text-muted { color: var(--gray-400); }
.text-right { text-align: right; }
.short-url  { color: var(--primary); text-decoration: none; font-weight: 500; }
.short-url:hover { text-decoration: underline; }
.link-title { font-size: .78rem; color: var(--gray-400); }
.folder-tag { background: var(--gray-100); padding: .1rem .4rem; border-radius: 4px; font-size: .75rem; }
.static-value { background: var(--gray-100); padding: .4rem .75rem; border-radius: 6px; font-size: .875rem; display: inline-block; }
.required { color: var(--danger); }
.plan-badge { background: #fef3c7; color: #92400e; padding: .1rem .4rem; border-radius: 4px; font-size: .75rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--gray-400); }
.actions-cell { white-space: nowrap; }
.btn-copy   { background: none; border: none; cursor: pointer; color: var(--primary); font-size: .8rem; padding: .1rem .3rem; }
.btn-copy:hover { text-decoration: underline; }
.upgrade-hint { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: .75rem 1rem; font-size: .875rem; margin-top: 1rem; }
.upgrade-hint a { color: var(--primary); font-weight: 600; }

/* ---- Filters bar ---- */
.filters-bar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.input-search { padding: .4rem .75rem; border: 1px solid var(--gray-200); border-radius: 6px; font-size: .875rem; }

/* ---- Page header ---- */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; }
.header-actions { display: flex; gap: .75rem; align-items: center; }

/* ---- Analytics ---- */
.analytics-grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.period-selector { display: flex; gap: .25rem; }
.period-btn { padding: .3rem .7rem; border-radius: 6px; background: var(--gray-200); color: var(--gray-600); text-decoration: none; font-size: .8rem; }
.period-btn.active { background: var(--primary); color: #fff; }
.alert-info { background: #dbeafe; color: #1e40af; padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }

/* ---- Pricing ---- */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.5rem; margin: 2rem 0; }
.pricing-card { background: #fff; border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); position: relative; }
.pricing-card-highlight { border: 2px solid var(--primary); }
.pricing-badge { background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; padding: .2rem .6rem; border-radius: 99px; display: inline-block; margin-bottom: .75rem; }
.pricing-badge-green { background: var(--success); }
.price { font-size: 2.5rem; font-weight: 700; color: var(--gray-800); margin: .75rem 0; }
.price span { font-size: 1rem; font-weight: 400; color: var(--gray-400); }
.price-sub { font-size: .875rem; color: var(--gray-400); margin-top: -.5rem; margin-bottom: .75rem; }
.features-list { list-style: none; margin: 1rem 0 1.5rem; }
.features-list li { padding: .3rem 0; font-size: .875rem; color: var(--gray-600); }
.faq-section { margin-top: 3rem; }
.faq-section h2 { margin-bottom: 1rem; }
.faq-item { margin-bottom: 1rem; }
.faq-item p { color: var(--gray-600); font-size: .875rem; margin-top: .25rem; }

/* ---- Hero ---- */
.hero { text-align: center; padding: 3rem 1rem; }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: .75rem; }
.hero p { color: var(--gray-600); font-size: 1.1rem; margin-bottom: 2rem; }
.hero-box { max-width: 600px; margin: 0 auto; }
.anon-link-form { display: flex; gap: .5rem; }
.anon-link-form input { flex: 1; }
.anon-result { background: var(--gray-100); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
.features-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5rem; margin: 3rem 0; }
.feature-item { text-align: center; }
.feature-icon { font-size: 2rem; margin-bottom: .5rem; }
.feature-item h3 { font-size: 1rem; margin-bottom: .25rem; }
.feature-item p { font-size: .875rem; color: var(--gray-600); }
.cta-center { text-align: center; margin: 2rem 0; display: flex; gap: 1rem; justify-content: center; }
.billing-note { text-align: center; color: var(--gray-400); font-size: .875rem; margin-top: 1rem; }

/* ---- Settings tabs ---- */
.settings-tabs { display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid var(--gray-200); }
.tab { padding: .6rem 1.25rem; color: var(--gray-600); text-decoration: none; font-size: .875rem; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- Advanced section ---- */
.advanced-section { margin-top: 1rem; border: 1px solid var(--gray-200); border-radius: var(--radius); }
.advanced-section summary { padding: .75rem 1rem; cursor: pointer; font-weight: 600; font-size: .875rem; color: var(--gray-600); }
.advanced-section > *:not(summary) { padding: 1rem; }

/* ---- QR ---- */
.qr-card { text-align: center; max-width: 400px; }
.qr-url { font-size: .875rem; color: var(--gray-600); margin: 1rem 0; word-break: break-all; }
.qr-actions { display: flex; flex-direction: column; gap: .75rem; align-items: center; }
.qr-style-panel summary { cursor: pointer; color: var(--primary); font-size: .875rem; }

/* ---- Token display ---- */
.token-display { display: block; background: var(--gray-100); padding: .5rem .75rem; border-radius: 6px; font-family: monospace; font-size: .85rem; word-break: break-all; margin: .5rem 0; }
.code-block { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: var(--radius); font-size: .8rem; overflow-x: auto; white-space: pre; }

/* ---- Upgrade card ---- */
.upgrade-card { background: linear-gradient(135deg, var(--primary), var(--primary-dk)); color: #fff; border-radius: var(--radius); padding: 1.5rem; display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.upgrade-card .btn-upgrade { background: #fff; color: var(--primary); }

/* ---- Pro status ---- */
.pro-status-card { border: 2px solid var(--primary); }
.pro-badge { font-size: 1.25rem; font-weight: 700; color: var(--primary); margin-bottom: .5rem; }

/* ---- Bulk actions ---- */
.bulk-actions { display: flex; gap: .75rem; align-items: center; background: #eff6ff; padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }

/* ---- Link hero ---- */
.link-hero { padding: .5rem 0 1rem; }
.link-short-url { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.link-short-url a { font-size: 1.25rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.link-destination { color: var(--gray-600); font-size: .875rem; word-break: break-all; margin-bottom: .5rem; }
.link-meta { font-size: .8rem; color: var(--gray-400); }

/* ---- Progress bar ---- */
.progress-bar { background: var(--gray-200); border-radius: 99px; height: 6px; margin-top: .5rem; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 99px; transition: width .3s; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .navbar-menu { gap: .5rem; font-size: .8rem; }
  .hero h1 { font-size: 1.75rem; }
  .anon-link-form { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cta-center { flex-direction: column; }
  .pricing-grid { grid-template-columns: 1fr; }
}

/* ===== Piani pricing ===== */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  max-width: 800px;
  margin: 2rem auto;
}
.plan-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 2rem;
  position: relative;
}
.plan-card.highlighted {
  border: 2px solid #6366f1;
}
.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #6366f1;
  color: #fff;
  font-size: 12px;
  padding: 4px 16px;
  border-radius: 20px;
  font-weight: 500;
}
.plan-header h2 {
  font-size: 22px;
  margin-bottom: 0.5rem;
}
.plan-price {
  font-size: 36px;
  font-weight: 700;
  margin: 1rem 0;
}
.plan-price span {
  font-size: 16px;
  font-weight: 400;
  color: #6b7280;
}
.plan-price small {
  display: block;
  font-size: 13px;
  color: #6b7280;
  font-weight: 400;
}
.plan-features {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}
.plan-features li {
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid #f3f4f6;
}
.plan-features li.disabled {
  color: #9ca3af;
}
.btn-current {
  display: block;
  text-align: center;
  padding: 10px;
  background: #f3f4f6;
  border-radius: 8px;
  color: #6b7280;
  font-size: 14px;
}
.btn-secondary {
  display: block;
  text-align: center;
  padding: 10px;
  border: 1px solid #6366f1;
  border-radius: 8px;
  color: #6366f1;
  font-size: 14px;
  text-decoration: none;
}
.subtitle {
  color: #6b7280;
  margin-top: 0.25rem;
}
@media (max-width: 600px) {
  .plans-grid { grid-template-columns: 1fr; }
}
