/* Foursome Design System - Tailwind CSS v4 */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=IBM+Plex+Mono&display=swap');

/* Tailwind theme customization */
@theme {
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

/* Base styles */
* {
  box-sizing: border-box;
}

/* Disable dragging for app-like feel */
img, iconify-icon, svg, a, button {
  -webkit-user-drag: none;
  user-drag: none;
}

/* Prevent text selection on interactive elements */
a, button, [role="button"], .cursor-pointer {
  -webkit-user-select: none;
  user-select: none;
}

/* Prevent touch callout (long-press menu) on iOS */
a, button, img {
  -webkit-touch-callout: none;
}

html {
  font-family: 'DM Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  padding-top: env(safe-area-inset-top);
  min-height: 100vh;
  min-height: 100dvh;
}

/* Light mode (default) */
:root {
  --color-bg: rgb(250 250 249); /* stone-50 */
  --color-bg-card: rgb(255 255 255); /* white */
  --color-border: rgb(231 229 228); /* stone-200 */
  --color-text: rgb(28 25 23); /* stone-900 */
  --color-text-muted: rgb(120 113 108); /* stone-500 */
  --color-accent: rgb(16 185 129); /* emerald-500 */
  --color-accent-hover: rgb(5 150 105); /* emerald-600 */
  --color-accent-light: rgb(209 250 229); /* emerald-100 */
}

body {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Dark mode */
.dark {
  --color-bg: rgb(12 10 9); /* stone-950 */
  --color-bg-card: rgb(28 25 23); /* stone-900 */
  --color-border: rgb(41 37 36); /* stone-800 */
  --color-text: rgb(245 245 244); /* stone-100 */
  --color-text-muted: rgb(168 162 158); /* stone-400 */
  --color-accent-light: rgb(6 78 59); /* emerald-900 */
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --color-bg: rgb(12 10 9); /* stone-950 */
    --color-bg-card: rgb(28 25 23); /* stone-900 */
    --color-border: rgb(41 37 36); /* stone-800 */
    --color-text: rgb(245 245 244); /* stone-100 */
    --color-text-muted: rgb(168 162 158); /* stone-400 */
    --color-accent-light: rgb(6 78 59); /* emerald-900 */
  }
  html:not([data-theme="light"]) body {
    background: rgb(12 10 9); /* stone-950 */
    color: rgb(245 245 244); /* stone-100 */
  }
}

/* Explicit dark mode */
html[data-theme="dark"] {
  --color-bg: rgb(12 10 9); /* stone-950 */
  --color-bg-card: rgb(28 25 23); /* stone-900 */
  --color-border: rgb(41 37 36); /* stone-800 */
  --color-text: rgb(245 245 244); /* stone-100 */
  --color-text-muted: rgb(168 162 158); /* stone-400 */
  --color-accent-light: rgb(6 78 59); /* emerald-900 */
}
html[data-theme="dark"] body {
  background: rgb(12 10 9); /* stone-950 */
  color: rgb(245 245 244); /* stone-100 */
}

/* Explicit light mode */
html[data-theme="light"] body {
  background: rgb(250 250 249); /* stone-50 */
  color: rgb(28 25 23); /* stone-900 */
}

/* Group color utilities */
.group-color-emerald { --group-color: rgb(16 185 129); }
.group-color-sky { --group-color: rgb(14 165 233); }
.group-color-amber { --group-color: rgb(245 158 11); }
.group-color-violet { --group-color: rgb(139 92 246); }
.group-color-rose { --group-color: rgb(244 63 94); }
.group-color-cyan { --group-color: rgb(6 182 212); }
.group-color-orange { --group-color: rgb(249 115 22); }
.group-color-pink { --group-color: rgb(236 72 153); }

/* Accent color utilities (user preference) */
.accent-amber {
  --color-accent: rgb(245 158 11);
  --color-accent-hover: rgb(217 119 6);
  --color-accent-light: rgb(254 243 199);
}
.accent-emerald {
  --color-accent: rgb(16 185 129);
  --color-accent-hover: rgb(5 150 105);
  --color-accent-light: rgb(209 250 229);
}
.accent-sky {
  --color-accent: rgb(14 165 233);
  --color-accent-hover: rgb(2 132 199);
  --color-accent-light: rgb(224 242 254);
}
.accent-violet {
  --color-accent: rgb(139 92 246);
  --color-accent-hover: rgb(124 58 237);
  --color-accent-light: rgb(237 233 254);
}
.accent-rose {
  --color-accent: rgb(244 63 94);
  --color-accent-hover: rgb(225 29 72);
  --color-accent-light: rgb(255 228 230);
}
.accent-cyan {
  --color-accent: rgb(6 182 212);
  --color-accent-hover: rgb(8 145 178);
  --color-accent-light: rgb(207 250 254);
}
.accent-orange {
  --color-accent: rgb(249 115 22);
  --color-accent-hover: rgb(234 88 12);
  --color-accent-light: rgb(255 237 213);
}

/* Dark mode accent light overrides */
[data-theme="dark"] .accent-amber { --color-accent-light: rgb(120 53 15); }
[data-theme="dark"] .accent-emerald { --color-accent-light: rgb(6 78 59); }
[data-theme="dark"] .accent-sky { --color-accent-light: rgb(12 74 110); }
[data-theme="dark"] .accent-violet { --color-accent-light: rgb(76 29 149); }
[data-theme="dark"] .accent-rose { --color-accent-light: rgb(136 19 55); }
[data-theme="dark"] .accent-cyan { --color-accent-light: rgb(22 78 99); }
[data-theme="dark"] .accent-orange { --color-accent-light: rgb(124 45 18); }

/* Accent color utility classes for use in templates */
.bg-accent { background-color: var(--color-accent); }
.bg-accent:hover { background-color: var(--color-accent-hover); }
.bg-accent-light { background-color: var(--color-accent-light); }
.text-accent { color: var(--color-accent); }
.text-accent-dark { color: var(--color-accent-hover); }
.border-accent { border-color: var(--color-accent); }
.ring-accent, .focus\:ring-accent:focus { --tw-ring-color: var(--color-accent) !important; }
.focus\:ring-accent:focus { box-shadow: 0 0 0 3px var(--color-accent) !important; border-color: transparent !important; }
.focus\:border-transparent:focus { border-color: transparent !important; }
.from-accent { --tw-gradient-from: var(--color-accent); --tw-gradient-to: transparent; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.to-accent-dark { --tw-gradient-to: var(--color-accent-hover); }
.accent-accent { accent-color: var(--color-accent); }

/* App shell layout */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 80px; /* space for bottom nav */
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-card);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.15s;
}

.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--color-accent);
}

.bottom-nav svg {
  width: 24px;
  height: 24px;
}

/* Top navigation */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
}

.top-nav h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

/* Card styles */
.card {
  background: var(--color-bg-card);
  border-radius: 16px;
  border: 1px solid var(--color-border);
  overflow: hidden;
  padding: 16px;
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.card-body {
  padding: 16px;
}

/* Button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

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

.btn-secondary {
  background: rgb(231 229 228); /* stone-200 */
  color: rgb(68 64 60); /* stone-700 */
}

.dark .btn-secondary {
  background: rgb(41 37 36); /* stone-800 */
  color: rgb(214 211 209); /* stone-300 */
}

.btn-secondary:hover {
  background: rgb(214 211 209); /* stone-300 */
}

.dark .btn-secondary:hover {
  background: rgb(68 64 60); /* stone-700 */
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
}

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: rgb(231 229 228);
}

.dark .avatar {
  background: rgb(68 64 60);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 600;
  font-size: 14px;
  color: white;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-success {
  background: rgb(220 252 231); /* green-100 */
  color: rgb(22 101 52); /* green-800 */
}

.dark .badge-success {
  background: rgb(20 83 45 / 0.3); /* green-900/30 */
  color: rgb(134 239 172); /* green-300 */
}

.badge-warning {
  background: rgb(254 249 195); /* yellow-100 */
  color: rgb(133 77 14); /* yellow-800 */
}

.dark .badge-warning {
  background: rgb(113 63 18 / 0.3); /* yellow-900/30 */
  color: rgb(253 224 71); /* yellow-300 */
}

.badge-muted {
  background: rgb(231 229 228); /* stone-200 */
  color: rgb(120 113 108); /* stone-500 */
}

.dark .badge-muted {
  background: rgb(41 37 36); /* stone-800 */
  color: rgb(168 162 158); /* stone-400 */
}

/* Group color badges */
.badge-emerald {
  background: rgb(209 250 229); /* emerald-100 */
  color: rgb(6 95 70); /* emerald-800 */
}
.dark .badge-emerald {
  background: rgb(6 78 59 / 0.3); /* emerald-900/30 */
  color: rgb(52 211 153); /* emerald-400 */
}

.badge-sky {
  background: rgb(224 242 254); /* sky-100 */
  color: rgb(7 89 133); /* sky-800 */
}
.dark .badge-sky {
  background: rgb(12 74 110 / 0.3); /* sky-900/30 */
  color: rgb(56 189 248); /* sky-400 */
}

.badge-amber {
  background: rgb(254 243 199); /* amber-100 */
  color: rgb(146 64 14); /* amber-800 */
}
.dark .badge-amber {
  background: rgb(120 53 15 / 0.3); /* amber-900/30 */
  color: rgb(251 191 36); /* amber-400 */
}

.badge-violet {
  background: rgb(237 233 254); /* violet-100 */
  color: rgb(91 33 182); /* violet-800 */
}
.dark .badge-violet {
  background: rgb(76 29 149 / 0.3); /* violet-900/30 */
  color: rgb(167 139 250); /* violet-400 */
}

.badge-rose {
  background: rgb(255 228 230); /* rose-100 */
  color: rgb(159 18 57); /* rose-800 */
}
.dark .badge-rose {
  background: rgb(136 19 55 / 0.3); /* rose-900/30 */
  color: rgb(251 113 133); /* rose-400 */
}

.badge-cyan {
  background: rgb(207 250 254); /* cyan-100 */
  color: rgb(21 94 117); /* cyan-800 */
}
.dark .badge-cyan {
  background: rgb(22 78 99 / 0.3); /* cyan-900/30 */
  color: rgb(34 211 238); /* cyan-400 */
}

.badge-orange {
  background: rgb(255 237 213); /* orange-100 */
  color: rgb(154 52 18); /* orange-800 */
}
.dark .badge-orange {
  background: rgb(124 45 18 / 0.3); /* orange-900/30 */
  color: rgb(251 146 60); /* orange-400 */
}

.badge-pink {
  background: rgb(252 231 243); /* pink-100 */
  color: rgb(157 23 77); /* pink-800 */
}
.dark .badge-pink {
  background: rgb(131 24 67 / 0.3); /* pink-900/30 */
  color: rgb(244 114 182); /* pink-400 */
}

/* Game card */
.game-card {
  background: var(--color-bg-card);
  border-radius: 16px;
  border: 1px solid var(--color-border);
  overflow: hidden;
  margin-bottom: 12px;
}

.game-card-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.game-card-body {
  padding: 0 16px 16px;
}

.game-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 8px;
}

/* Player spots */
.player-spots {
  display: flex;
  gap: 8px;
}

.player-spot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-spot.filled {
  border: none;
}

.player-spot.open {
  background: transparent;
  color: var(--color-text-muted);
}

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

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Form elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-card);
  color: var(--color-text);
}

/* search inputs with icon need left padding */
input[type="search"] {
  padding-left: 2.5rem;
}

/* Style the native search clear button to match theme icons (stone-400/500) */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  height: 16px !important;
  width: 16px !important;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a8a29e'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E") center/contain no-repeat !important;
  cursor: pointer;
}

[data-theme="dark"] input[type="search"]::-webkit-search-cancel-button,
html[data-theme="dark"] input[type="search"]::-webkit-search-cancel-button {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2378716c'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E") center/contain no-repeat !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) input[type="search"]::-webkit-search-cancel-button {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2378716c'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E") center/contain no-repeat !important;
  }
}

/* Custom checkbox styling */
input[type="checkbox"].checkbox-accent {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgb(168 162 158); /* stone-400 */
  border-radius: 0.25rem;
  background: rgb(250 250 249); /* stone-50 - matches row background */
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.dark input[type="checkbox"].checkbox-accent,
[data-theme="dark"] input[type="checkbox"].checkbox-accent {
  background: rgb(41 37 36); /* stone-800 - matches dark row background */
  border-color: rgb(87 83 78); /* stone-600 */
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) input[type="checkbox"].checkbox-accent {
    background: rgb(41 37 36); /* stone-800 */
    border-color: rgb(87 83 78); /* stone-600 */
  }
}

input[type="checkbox"].checkbox-accent:checked {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
}

input[type="checkbox"].checkbox-accent:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Ensure dark mode checked state also uses accent */
.dark input[type="checkbox"].checkbox-accent:checked,
[data-theme="dark"] input[type="checkbox"].checkbox-accent:checked {
  background: var(--color-accent) !important;
  border-color: var(--color-accent) !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) input[type="checkbox"].checkbox-accent:checked {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
  }
}

input[type="checkbox"].checkbox-accent:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

/* form labels - don't override when label has flex class (e.g. checkbox rows) */
label:not([class*="flex"]) {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@keyframes slide-up {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.animate-fade-in {
  animation: fade-in 0.2s ease-out;
}

.animate-slide-up {
  animation: slide-up 0.3s ease-out;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  animation: slide-up 0.3s ease-out;
  z-index: 50;
}

.toast.error {
  background: rgb(254 226 226); /* red-100 */
  color: rgb(153 27 27); /* red-800 */
  border: 1px solid rgb(252 165 165); /* red-300 */
}

.dark .toast.error {
  background: rgb(127 29 29 / 0.3); /* red-900/30 */
  color: rgb(252 165 165); /* red-300 */
  border: 1px solid rgb(127 29 29); /* red-900 */
}

.toast.success {
  background: rgb(220 252 231); /* green-100 */
  color: rgb(22 101 52); /* green-800 */
  border: 1px solid rgb(134 239 172); /* green-300 */
}

.dark .toast.success {
  background: rgb(20 83 45 / 0.3); /* green-900/30 */
  color: rgb(134 239 172); /* green-300 */
  border: 1px solid rgb(20 83 45); /* green-900 */
}

/* Loading skeleton animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Large control size mode - increases touch targets for mobile */
/* exclude toggle switches (w-11 h-6) from min-height */
body[data-control-size="large"] button:not(.w-11),
body[data-control-size="large"] a[role="button"],
body[data-control-size="large"] [data-on-click]:not(button) {
  min-height: 44px;
}

/* increase padding on small buttons (but not toggles) */
body[data-control-size="large"] button.p-2:not(.w-11),
body[data-control-size="large"] [data-on-click].p-2 {
  padding: 12px;
}

/* increase accent color picker size */
body[data-control-size="large"] button.w-10.h-10.rounded-full {
  width: 48px;
  height: 48px;
}

/* increase icon button touch targets */
body[data-control-size="large"] button:has(> iconify-icon:only-child):not(.w-11) {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
