/* =============================================================
   TRYTRACK COMPONENTS.CSS  — v2
   Buttons · Cards · Forms · Tables · Badges · Toasts · Loader
   ============================================================= */

/* ── Buttons ───────────────────────────────────────────────── */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost,
.btn-sm {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform var(--ease), box-shadow var(--ease), background var(--ease), border-color var(--ease), color var(--ease);
}

/* Shimmer sweep */
.btn-primary::before,
.btn-secondary::before,
.btn-danger::before,
.btn-ghost::before,
.btn-sm::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.14), transparent);
  transition: 0.5s ease;
}

.btn-primary:hover::before,
.btn-secondary:hover::before,
.btn-danger:hover::before,
.btn-ghost:hover::before,
.btn-sm:hover::before { left: 120%; }

/* Primary */
.btn-primary,
.btn-sm {
  background: var(--gradient-primary);
  box-shadow: 0 10px 26px rgba(37,99,235,0.22);
}

.btn-primary:hover,
.btn-sm:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(37,99,235,0.30);
}

/* Secondary */
.btn-secondary,
.btn-ghost {
  background: rgba(56,189,248,0.10);
  border: 1px solid rgba(56,189,248,0.22);
  color: #7dd3fc;
}

.btn-secondary:hover,
.btn-ghost:hover {
  transform: translateY(-2px);
  background: rgba(56,189,248,0.16);
  border-color: rgba(56,189,248,0.38);
  color: #fff;
}

/* Danger */
.btn-danger {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.22);
  color: #fca5a5;
}

.btn-danger:hover {
  transform: translateY(-2px);
  background: rgba(239,68,68,0.20);
  border-color: rgba(239,68,68,0.38);
}

/* Small variant */
.btn-sm { padding: 10px 16px; border-radius: var(--r-pill); font-size: 12px; }

/* ── Cards ─────────────────────────────────────────────────── */

.content-card,
.form-card,
.chart-card {
  position: relative;
  overflow: hidden;
  padding: 28px;
  margin-bottom: 22px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
  min-width: 0;
}

/* Subtle glow behind each card */
.content-card::before,
.form-card::before,
.chart-card::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -100px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56,189,248,0.10), transparent 70%);
  pointer-events: none;
}

.content-card:hover,
.chart-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56,189,248,0.26);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(56,189,248,0.06);
}

.content-card h2,
.form-card h2,
.chart-card h2 {
  margin-bottom: 20px;
  font-size: 20px;
  font-weight: 900;
}

/* App card — premium dark glass */
.app-card {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border-radius: 26px;
  border: 1px solid rgba(56,189,248,0.10);
  background:
    radial-gradient(circle at top right, rgba(56,189,248,0.08), transparent 34%),
    linear-gradient(135deg, rgba(15,23,42,0.94), rgba(2,6,23,0.84));
  box-shadow: 0 22px 55px rgba(0,0,0,0.30), inset 0 1px 0 rgba(255,255,255,0.03);
  backdrop-filter: blur(18px);
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
  min-width: 0;
}

.app-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56,189,248,0.24);
  box-shadow: 0 32px 75px rgba(0,0,0,0.38), 0 0 0 1px rgba(56,189,248,0.06);
}

/* Stat card */
.stat-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  min-width: 0;
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56,189,248,0.24);
  box-shadow: var(--shadow-md);
}

/* Premium list-item card */
.app-list-card {
  position: relative;
  overflow: hidden;
  padding: 22px 24px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(56,189,248,0.07), transparent 36%),
    linear-gradient(135deg, rgba(15,23,42,0.92), rgba(2,6,23,0.82));
  border: 1px solid rgba(148,163,184,0.14);
  box-shadow: 0 18px 50px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.02);
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
  min-width: 0;
}

.app-list-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56,189,248,0.22);
  box-shadow: 0 26px 65px rgba(0,0,0,0.34);
}

/* ── Forms ─────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.form-group label,
.auth-form-group label {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  background: rgba(15,23,42,0.72);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

input:hover,
select:hover,
textarea:hover { border-color: rgba(148,163,184,0.30); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(56,189,248,0.55);
  background: rgba(15,23,42,0.88);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.12);
}

select { appearance: none; cursor: pointer; }
textarea { resize: vertical; min-height: 110px; }

/* Checkbox / radio */
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Grid forms */
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.form-span-2 { grid-column: span 2; }
.form-span-full { grid-column: 1 / -1; }

/* Auth form */
.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

/* ── Tables ────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

thead th {
  padding: 14px 18px;
  text-align: left;
  background: rgba(2,6,23,0.52);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(148,163,184,0.08);
  transition: background var(--ease);
}

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

tbody tr:hover { background: rgba(56,189,248,0.04); }

tbody td {
  padding: 14px 18px;
  color: var(--text-soft);
  font-size: 14px;
  vertical-align: middle;
}

/* ── Badges / Chips ────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success { background: var(--success-soft);  color: #86efac; border: 1px solid rgba(34,197,94,0.24); }
.badge-warning { background: var(--warning-soft);  color: #fcd34d; border: 1px solid rgba(245,158,11,0.24); }
.badge-danger  { background: var(--danger-soft);   color: #fca5a5; border: 1px solid rgba(239,68,68,0.24); }
.badge-primary { background: var(--primary-soft);  color: var(--primary); border: 1px solid rgba(56,189,248,0.24); }
.badge-neutral { background: rgba(148,163,184,0.12); color: var(--muted-strong); border: 1px solid rgba(148,163,184,0.20); }

/* Status dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-ready   { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.6); }
.dot-warning { background: var(--warning); box-shadow: 0 0 8px rgba(245,158,11,0.6); }
.dot-danger  { background: var(--danger);  box-shadow: 0 0 8px rgba(239,68,68,0.6); }
.dot-neutral { background: var(--muted); }

/* ── Toasts ────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 300px;
  max-width: 420px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(8,15,32,0.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.25s ease, transform 0.25s ease, height 0.28s ease, margin 0.28s ease, padding 0.28s ease;
  overflow: hidden;
}

.toast.show { opacity: 1; transform: translateX(0); }

.toast-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px; font-weight: 900;
}

.toast-content { flex: 1; min-width: 0; }
.toast-title   { margin-bottom: 3px; font-size: 12px; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }
.toast-message { font-size: 13px; line-height: 1.5; color: var(--text-soft); }

.toast-close-btn {
  width: 26px; height: 26px;
  border: none; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
  font-size: 11px; font-weight: 900;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--ease), color var(--ease);
}
.toast-close-btn:hover { background: rgba(255,255,255,0.16); color: #fff; }

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--primary); }

.toast-success .toast-icon { background: var(--success-soft); color: #4ade80; }
.toast-error   .toast-icon { background: var(--danger-soft);  color: #f87171; }
.toast-warning .toast-icon { background: var(--warning-soft); color: #fbbf24; }
.toast-info    .toast-icon { background: var(--primary-soft); color: #7dd3fc; }

/* ── Global Loader ─────────────────────────────────────────── */

.global-loader {
  position: fixed; inset: 0;
  z-index: var(--z-loader);
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,20,0.82);
  backdrop-filter: blur(6px);
}

.global-loader.hidden { display: none; }

.rugby-loader { text-align: center; color: #fff; }
.rugby-loader p { margin-top: 16px; font-size: 14px; font-weight: 700; letter-spacing: 0.05em; opacity: 0.9; }

.rugby-ball {
  width: 80px; height: 52px;
  position: relative; margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #f5f5f5, #d9d9d9);
  transform: rotate(-25deg);
  animation: rugby-roll 1.2s linear infinite, rugby-bounce 0.9s ease-in-out infinite;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

.rugby-ball::before {
  content: "";
  position: absolute;
  width: 8px; height: 100%;
  left: 50%; transform: translateX(-50%);
  background: #222;
}

.rugby-ball::after {
  content: "";
  position: absolute;
  width: 40px; height: 5px;
  top: 50%; left: 50%;
  border-radius: 10px;
  transform: translate(-50%, -50%);
  background: #222;
}

@keyframes rugby-roll {
  from { transform: rotate(-25deg) rotate(0deg); }
  to   { transform: rotate(-25deg) rotate(360deg); }
}

@keyframes rugby-bounce {
  0%, 100% { translate: 0 0; }
  50%       { translate: 0 -8px; }
}

/* ── Auth messages ─────────────────────────────────────────── */

.auth-message,
.form-message {
  margin-bottom: 16px;
  padding: 13px 15px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
}

.auth-message-success, .form-message-success { background: var(--success-soft); border: 1px solid rgba(34,197,94,0.26); color: #86efac; }
.auth-message-error,   .form-message-error   { background: var(--danger-soft);  border: 1px solid rgba(239,68,68,0.26);  color: #fca5a5; }
.auth-message-warning, .form-message-warning { background: var(--warning-soft); border: 1px solid rgba(245,158,11,0.26); color: #fcd34d; }

/* ── Ring / Donut progress ─────────────────────────────────── */

.progress-ring {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--value, 0%) * 3.6deg), rgba(255,255,255,0.06) 0);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(56,189,248,0.18);
}

.progress-ring-inner {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(2,6,23,0.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
}

.progress-ring-inner strong { font-size: 16px; font-weight: 900; color: #fff; line-height: 1; }
.progress-ring-inner span   { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── List items ────────────────────────────────────────────── */

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(2,6,23,0.42);
  border: 1px solid rgba(148,163,184,0.10);
  transition: background var(--ease), border-color var(--ease);
  min-width: 0;
}

.list-item:hover {
  background: rgba(56,189,248,0.06);
  border-color: rgba(56,189,248,0.18);
}

/* ── Responsive Component Adjustments ─────────────────────── */

@media (max-width: 1100px) {
  .grid-form,
  .form-span-2 { grid-template-columns: repeat(2, 1fr); }
  .form-span-2 { grid-column: span 2; }
}

@media (max-width: 700px) {
  .grid-form { grid-template-columns: 1fr; }
  .form-span-2, .form-span-full { grid-column: span 1; }

  .toast-container { left: 14px; right: 14px; bottom: 16px; }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

@media (max-width: 480px) {
  input, select, textarea { font-size: 16px; } /* Prevent iOS zoom */

  .content-card, .form-card, .chart-card { padding: 20px; }

  .btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
    width: 100%;
    justify-content: center;
  }
}
