/**
 * Florida Predictor — Components v3.1 (F2+F3)
 * Cards, Buttons, Tables, Badges, Form Elements
 * 
 * CHANGELOG v3.1:
 * - Card: glassmorphism hero, accent glow border on hover
 * - Balls: circular with inner shadow + shine pseudo-element
 * - Table: zebra striping, result highlight, hover glow row
 * - Buttons: added primary, ghost, icon-only variants
 * - Badges: refined dark mode contrast
 * - Loading: skeleton shimmer placeholders
 */

/* ============================================================================
   CARD BASE
   ============================================================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  transition: box-shadow 0.3s var(--ease-smooth), 
              transform 0.3s var(--ease-smooth),
              border-color 0.3s var(--ease-smooth);
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: rgba(0, 168, 255, 0.15);
}

/* Subtle gradient glow on card hover (top edge) */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s var(--ease-smooth);
}

.card:hover::before {
  opacity: 1;
}

/* Hero card variant */
.card--hero {
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  background: linear-gradient(
    135deg,
    var(--bg-surface) 0%,
    var(--bg-surface-hover) 100%
  );
}

:root.dark .card--hero {
  background: linear-gradient(
    135deg,
    var(--bg-surface) 0%,
    rgba(0, 168, 255, 0.03) 100%
  );
}

/* Hero cards glow on hover */
.card--hero:hover {
  box-shadow: var(--shadow-lg), 0 0 30px rgba(0, 168, 255, 0.06);
}

/* Teaser card variant */
.card--teaser {
  padding: var(--space-6) var(--space-8);
  border: 1px dashed var(--border-color);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-hover));
}

/* Card header row (icon + label) */
.card-header-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-icon-wrap {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 168, 255, 0.25);
  flex-shrink: 0;
  position: relative;
}

/* Subtle inner glow */
.card-icon-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.2), transparent 60%);
  pointer-events: none;
}

.card-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

/* ============================================================================
   SECTION HEADERS
   ============================================================================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.section-title-row svg {
  color: var(--fp-secondary);
  flex-shrink: 0;
}

.section-title-row h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.section-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: calc(-1 * var(--space-3)) 0 var(--space-5);
}

@media (max-width: 768px) {
  .section-header { flex-direction: column; align-items: flex-start; }
  .section-title-row h2 { font-size: 1rem; }
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge--warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-warning-dark);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge--success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--color-success-dark);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge--info {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-info-dark);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

:root.dark .badge--warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning-light);
  border-color: rgba(245, 158, 11, 0.2);
}

:root.dark .badge--success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success-light);
  border-color: rgba(16, 185, 129, 0.2);
}

:root.dark .badge--info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-info-light);
  border-color: rgba(59, 130, 246, 0.2);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

/* --- Refresh button --- */
.btn-refresh {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

.btn-refresh:hover {
  color: var(--fp-secondary);
  border-color: var(--fp-secondary);
  background: rgba(0, 168, 255, 0.06);
  box-shadow: 0 0 12px rgba(0, 168, 255, 0.1);
}

.btn-refresh:hover svg {
  transform: rotate(180deg);
  transition: transform 0.4s var(--ease-smooth);
}

.btn-refresh:active {
  transform: scale(0.92);
}

/* Refresh button spinning state */
.btn-refresh.is-refreshing {
  pointer-events: none;
  opacity: 0.7;
}

.btn-refresh.is-refreshing svg {
  animation: spin 0.8s linear infinite;
}

/* --- Primary button --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--gradient-primary);
  color: white;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0, 168, 255, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(0, 168, 255, 0.35);
  transform: translateY(-1px);
}

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

/* --- Ghost button --- */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: transparent;
  color: var(--fp-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0, 168, 255, 0.25);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  background: rgba(0, 168, 255, 0.06);
  border-color: var(--fp-secondary);
}

/* ============================================================================
   PERIOD SELECTOR
   ============================================================================ */

.period-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-surface-hover);
  padding: 3px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.period-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: var(--font-body);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  background: transparent;
}

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

.period-btn.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 168, 255, 0.3);
}

/* ============================================================================
   TABLE (F3 Redesign)
   ============================================================================ */

.lotteries-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.lotteries-table {
  font-size: 0.8125rem;
  width: 100%;
  table-layout: fixed;
}

.lotteries-table thead {
  background: var(--glass-blue);
}

:root.dark .lotteries-table thead {
  background: rgba(0, 168, 255, 0.06);
}

.lotteries-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-color);
}

.lotteries-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

/* Column widths (table-layout: fixed) */
.lotteries-table th:nth-child(1),
.lotteries-table td:nth-child(1) {
  width: 30%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lotteries-table th:nth-child(2),
.lotteries-table td:nth-child(2) {
  width: 45%;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.lotteries-table th:nth-child(3),
.lotteries-table td:nth-child(3) {
  width: 25%;
  white-space: nowrap;
}

/* Zebra striping */
.lotteries-table tbody tr:nth-child(even) {
  background: var(--glass-blue);
}

:root.dark .lotteries-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Hover glow */
.lotteries-table tbody tr {
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.lotteries-table tbody tr:hover {
  background: rgba(0, 168, 255, 0.06);
}

:root.dark .lotteries-table tbody tr:hover {
  background: rgba(0, 168, 255, 0.08);
}

.lotteries-table tbody tr:last-child td {
  border-bottom: none;
}

/* Lottery name column styling */
.lotteries-table td strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Result numbers column — monospaced + brand color */
.lotteries-table td:nth-child(2) {
  font-weight: 800;
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--fp-primary);
  letter-spacing: 0.02em;
}

:root.dark .lotteries-table td:nth-child(2) {
  color: var(--fp-secondary);
}

/* Date column */
.lotteries-table td:nth-child(3) {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.table-empty {
  text-align: center;
  padding: var(--space-8) !important;
  color: var(--text-tertiary) !important;
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.table-loading,
.heatmap-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--fp-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Skeleton shimmer placeholder */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-hover) 25%,
    var(--bg-surface) 50%,
    var(--bg-surface-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================================
   RESPONSIVE COMPONENT TWEAKS
   ============================================================================ */

@media (max-width: 768px) {
  .card { padding: var(--space-5); border-radius: var(--radius-xl); }
  .card--hero { padding: var(--space-5); }
  .card--teaser { padding: var(--space-5); }

  /* Table: tighter on mobile */
  .lotteries-table th,
  .lotteries-table td {
    padding: var(--space-2) var(--space-3);
    font-size: 0.75rem;
  }

  .lotteries-table th:nth-child(1),
  .lotteries-table td:nth-child(1) { width: 28%; }

  .lotteries-table th:nth-child(2),
  .lotteries-table td:nth-child(2) { width: 47%; }

  .lotteries-table th:nth-child(3),
  .lotteries-table td:nth-child(3) { width: 25%; }
}

@media (max-width: 480px) {
  .card { padding: var(--space-4); }

  /* Table: extra compact */
  .lotteries-table th,
  .lotteries-table td {
    padding: var(--space-1) var(--space-2);
    font-size: 0.6875rem;
  }

  .lotteries-table td:nth-child(2) {
    font-size: 0.625rem;
    letter-spacing: -0.01em;
  }
}

.badge--accent {
    background: rgba(212, 160, 23, 0.15);
    color: #d4a017;
}