/* ============================================
   WinnerPoints Web Portal - Shared Styles
   Apple-style design language
   ============================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
  /* Colors */
  --color-primary: #0071e3;
  --color-primary-hover: #0077ed;
  --color-secondary: #06c;
  --color-success: #34c759;
  --color-error: #ff3b30;
  --color-warning: #ff9500;

  /* Text */
  --color-text-dark: #1d1d1f;
  --color-text-medium: #424245;
  --color-text-light: #6e6e73;
  --color-text-muted: #86868b;

  /* Borders & Backgrounds */
  --color-border: #d2d2d7;
  --color-border-light: #e8e8ed;
  --color-bg: #fff;
  --color-bg-secondary: #f5f5f7;
  --color-disabled: #aeaeb2;

  /* Shadows */
  --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-standard: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.08);
  --shadow-primary: 0 12px 36px rgba(0, 113, 227, 0.12);

  /* Radii */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 980px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-standard: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-slow: 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Layout */
  --container-max: 980px;
  --container-padding: 22px;
  --header-height: 48px;

  /* Font */
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: 17px;
  line-height: 1.47;
  color: var(--color-text-dark);
  background-color: var(--color-bg);
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--color-text-dark);
  line-height: 1.1;
}

h1 { font-size: 48px; }
h2 { font-size: 32px; }
h3 { font-size: 24px; }
h4 { font-size: 21px; }

p {
  color: var(--color-text-medium);
  line-height: 1.47;
}

.text-muted {
  color: var(--color-text-muted);
  font-size: 14px;
}

.text-center { text-align: center; }

/* --- Layout --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.section {
  padding: 80px 0;
}

.section--alt {
  background-color: var(--color-bg-secondary);
}

/* --- Navigation Header --- */
.nav-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--container-padding);
  max-width: var(--container-max);
  margin: 0 auto;
}

.nav-header-wrap {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-border-light);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 18px;
  color: var(--color-text-dark);
  text-decoration: none;
}

.nav-logo img {
  height: 28px;
  width: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  font-size: 14px;
  color: var(--color-text-medium);
  transition: color var(--transition-fast);
}

.nav-links a:hover {
  color: var(--color-text-dark);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: all var(--transition-standard);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.02);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-secondary:hover {
  background-color: var(--color-primary);
  color: #fff;
  transform: scale(1.02);
}

.btn-text {
  background: none;
  color: var(--color-primary);
  padding: 8px 4px;
  border: none;
}

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

.btn-sm {
  font-size: 14px;
  padding: 10px 22px;
}

.btn-lg {
  font-size: 17px;
  padding: 14px 32px;
}

.btn-block {
  width: 100%;
}

/* --- Cards --- */
.card {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  padding: 32px;
  transition: all var(--transition-standard);
}

.card:hover {
  box-shadow: var(--shadow-standard);
}

.card--elevated {
  box-shadow: var(--shadow-subtle);
  border: none;
}

.card--elevated:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-4px);
}

.card--glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-dark);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  font-family: var(--font-family);
  font-size: 17px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text-dark);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input::placeholder {
  color: var(--color-disabled);
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.form-input.is-error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

.form-input.is-success {
  border-color: var(--color-success);
}

.form-error {
  font-size: 13px;
  color: var(--color-error);
  margin-top: 4px;
  display: none;
}

.form-group.has-error .form-error {
  display: block;
}

.form-group.has-error .form-input {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* --- Toast / Notifications --- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  box-shadow: var(--shadow-elevated);
  font-size: 15px;
  color: var(--color-text-dark);
  pointer-events: auto;
  animation: toast-in 0.4s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
  max-width: 380px;
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

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

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* --- Loading Spinner --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-standard);
}

.loading-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

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

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

/* --- Fade-in Animations --- */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

.animate-in {
  animation: fadeInUp 0.6s cubic-bezier(0.25, 0.1, 0.25, 1) both;
}

.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.2s; }
.animate-in:nth-child(4) { animation-delay: 0.3s; }

/* --- Utility Classes --- */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 32px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 32px; }

/* --- Page Shell (auth pages, dashboards) --- */
.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: 40px 0;
}

/* --- Auth Card (login / register) --- */
.auth-wrapper {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px var(--container-padding);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  padding: 48px 40px;
}

.auth-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
  text-align: center;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--color-text-light);
  font-size: 15px;
  margin-bottom: 32px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border-light);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 32px; }
  h2 { font-size: 24px; }
  h3 { font-size: 20px; }

  body { font-size: 15px; }

  .section {
    padding: 48px 0;
  }

  .card {
    padding: 24px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 32px 24px;
    box-shadow: none;
    border: 1px solid var(--color-border-light);
  }

  .nav-links {
    gap: 16px;
  }

  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: 100%;
  }

  .btn-lg {
    padding: 12px 24px;
    font-size: 15px;
  }
}

@media (min-width: 1441px) {
  .container {
    max-width: 1120px;
  }
}
