/* ========================================
   FIT Trainer Portal - Styles
   ======================================== */

:root {
  --fit-red: #D73930;
  --fit-red-hover: #c12f27;
  --fit-dark: #1A1A1A;
  --fit-black: #000000;
  --fit-body: #515251;
  --fit-light: #f5f5f5;
  --fit-border: #e0e0e0;
  --fit-white: #ffffff;
  --fit-green: #22c55e;
  --fit-yellow: #eab308;
  --fit-gray: #9ca3af;
  --radius: 6px;
  --radius-btn: 34px 0px 34px 0px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--fit-body);
  background: var(--fit-light);
  line-height: 1.5;
}

.screen { min-height: 100vh; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 28px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--fit-red);
  color: var(--fit-white);
  border-radius: var(--radius-btn);
}
.btn-primary:hover { background: var(--fit-red-hover); }
.btn-primary:disabled { background: var(--fit-gray); cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--fit-body);
  padding: 8px 16px;
  border-radius: var(--radius);
}
.btn-ghost:hover { background: rgba(0,0,0,0.05); }

/* ---- Auth Screen ---- */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fit-dark);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(215, 57, 48, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(215, 57, 48, 0.08) 0%, transparent 60%);
}

.auth-card {
  background: var(--fit-white);
  padding: 48px 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.auth-logo-img { height: 44px; filter: brightness(0); }
.auth-logo-iprov { height: 52px; filter: none; }

.auth-logo-pipe {
  color: var(--fit-border);
  font-size: 32px;
  font-weight: 200;
  line-height: 1;
}

.auth-divider {
  width: 48px;
  height: 3px;
  background: var(--fit-red);
  margin: 0 auto 24px;
  border-radius: 2px;
}

.auth-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--fit-dark);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--fit-gray);
  margin-bottom: 32px;
  line-height: 1.5;
}

#magic-link-form { display: flex; flex-direction: column; gap: 16px; }

#magic-link-form input {
  padding: 16px 18px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid var(--fit-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#magic-link-form input:focus {
  border-color: var(--fit-red);
  box-shadow: 0 0 0 3px rgba(215, 57, 48, 0.1);
}

.btn-full { width: 100%; justify-content: center; padding: 16px 28px; }

.auth-message {
  margin-top: 16px;
  font-size: 14px;
  color: var(--fit-green);
}
.auth-message.error { color: var(--fit-red); }

.auth-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--fit-gray);
  opacity: 0.7;
}

/* ---- App Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--fit-dark);
  color: var(--fit-white);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.logo-sm { height: 36px; }
.logo-iprov { height: 46px; filter: brightness(0) invert(1); }

.header-pipe {
  color: rgba(255,255,255,0.3);
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  justify-content: flex-end;
}

.user-email {
  font-size: 13px;
  color: var(--fit-gray);
}

#sign-out-btn { color: var(--fit-gray); text-transform: none; font-weight: 400; }
#sign-out-btn:hover { color: var(--fit-white); }

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  gap: 1px;
  background: var(--fit-border);
  border-bottom: 1px solid var(--fit-border);
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  background: var(--fit-white);
}

.stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--fit-dark);
  line-height: 1;
}

.stat-warn .stat-number { color: var(--fit-red); }

.stat-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fit-gray);
  margin-top: 4px;
}

/* ---- Controls ---- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-filter {
  display: flex;
  gap: 12px;
  flex: 1;
  flex-wrap: wrap;
}

.search-box, .filter-select {
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--fit-border);
  border-radius: var(--radius);
  background: var(--fit-white);
  outline: none;
}
.search-box { min-width: 220px; flex: 1; max-width: 320px; }
.search-box:focus, .filter-select:focus { border-color: var(--fit-red); }

/* ---- Trainer Grid ---- */
.trainer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
}

.trainer-card {
  background: var(--fit-white);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.trainer-card:hover { box-shadow: var(--shadow-md); }

.trainer-photo {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--fit-border);
  display: block;
}

.trainer-photo-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #e0e0e0 0%, #ccc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fit-gray);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.trainer-info { padding: 16px; }

.trainer-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--fit-dark);
  margin-bottom: 2px;
}

.trainer-location {
  font-size: 13px;
  color: var(--fit-gray);
  margin-bottom: 12px;
}

.trainer-badges {
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-radius: 100px;
}

.badge-complete {
  background: #dcfce7;
  color: #166534;
}

.badge-missing {
  background: #fef2f2;
  color: #991b1b;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-complete .badge-dot { background: #22c55e; }
.badge-missing .badge-dot { background: #ef4444; }

/* ---- Draft cards ---- */
.trainer-card-draft {
  opacity: 0.7;
  border: 2px dashed var(--fit-border);
}
.trainer-card-draft:hover { opacity: 1; }

.trainer-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-draft {
  background: #fef3c7;
  color: #92400e;
}
.badge-draft .badge-dot { background: #f59e0b; }

.trainer-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 100px;
}
.trainer-status-onboarding { background: #dbeafe; color: #1e40af; }
.trainer-status-departing { background: #fef2f2; color: #991b1b; }
.trainer-status-inactive { background: #f3f4f6; color: #6b7280; }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  background: var(--fit-white);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--fit-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--fit-gray);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--fit-dark); }

#change-request-form { padding: 24px; }

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fit-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--fit-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--fit-red);
}

.form-group textarea { resize: vertical; }

/* File Upload */
.file-upload { position: relative; }

.file-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  border: 2px dashed var(--fit-border);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color 0.2s;
}

.file-upload:hover .file-upload-label { border-color: var(--fit-red); }

.file-upload-icon { font-size: 24px; }
.file-upload-text { font-size: 13px; color: var(--fit-gray); }

.photo-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-top: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--fit-border);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--fit-dark);
  color: var(--fit-white);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.3s ease;
}

.toast-icon {
  color: var(--fit-green);
  font-size: 18px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Trainer Detail Modal ---- */
.modal-content-wide {
  max-width: 720px;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}

.detail-photo-col img {
  width: 100%;
  border-radius: 8px;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.detail-photo-col .trainer-photo-placeholder {
  border-radius: 8px;
}

.detail-info-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fit-gray);
}

.detail-value {
  font-size: 15px;
  color: var(--fit-dark);
}

.detail-value:empty::after {
  content: '\2014';
  color: var(--fit-border);
}

.detail-badges-row {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.detail-badge-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-bio {
  margin-top: 8px;
}

.detail-bio-text {
  font-size: 14px;
  color: var(--fit-body);
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
}

.detail-video {
  margin-top: 8px;
}

.detail-video iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: 6px;
}

.detail-actions {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--fit-border);
}

.trainer-card { cursor: pointer; }

/* ---- Demo mode ---- */
.demo-mode #auth-screen { display: none !important; }
.demo-mode #app-screen { display: block !important; }

/* ---- Loading ---- */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px;
  color: var(--fit-gray);
  font-size: 14px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .app-header { padding: 12px 16px; }
  .stats-bar { flex-wrap: wrap; }
  .stat { min-width: 33.33%; }
  .controls { padding: 16px; }
  .trainer-grid { padding: 0 16px 16px; grid-template-columns: 1fr; }
  .search-box { min-width: 100%; }
  .header-right .user-email { display: none; }
}
