/* Fitness Blueprint - iOS-style PWA */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #2e2e2e;
  --text: #f5f5f5;
  --text-dim: #999;
  --accent: #4ade80;
  --accent-dim: #2a4a32;
  --danger: #ef4444;
  --warning: #f59e0b;
  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
}

/* Header */
.header {
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 17px;
  font-weight: 600;
}

.header .subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.header-action {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* Day selector */
.day-selector {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.day-selector::-webkit-scrollbar { display: none; }

.day-pill {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
}
.day-pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 80px;
}

/* Section */
.section { margin-bottom: 24px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Card */
.card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.card-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.card-row:last-child { border-bottom: none; }
.card-row:active { background: var(--surface-2); }

.card-row.completed {
  opacity: 0.5;
}
.card-row.completed .row-title {
  text-decoration: line-through;
}

.row-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.row-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.row-checkbox.checked::after {
  content: '✓';
  color: var(--bg);
  font-weight: bold;
  font-size: 14px;
}

.row-content {
  flex: 1;
  min-width: 0;
}
.row-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 2px;
}
.row-meta {
  font-size: 13px;
  color: var(--text-dim);
}
.row-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-dim);
  margin-right: 6px;
  text-transform: uppercase;
}
.row-tag.superset {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Diet specific */
.diet-meal-header {
  padding: 14px 16px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.diet-meal-name {
  font-weight: 600;
  font-size: 15px;
}
.diet-meal-macros {
  font-size: 12px;
  color: var(--text-dim);
}

/* Empty state */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-text { font-size: 14px; line-height: 1.5; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-align: center;
  width: 100%;
  -webkit-appearance: none;
  background: var(--text);
  color: var(--bg);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-accent { background: var(--accent); color: var(--bg); }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tab bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 0 calc(8px + var(--safe-bot));
  z-index: 100;
}

.tab-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
}
.tab-bar-item.active { color: var(--accent); }
.tab-bar-icon { font-size: 22px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s;
}

.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bot));
  animation: slideUp 0.25s;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}
.modal-text {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Form */
.input, .textarea {
  width: 100%;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  -webkit-appearance: none;
}
.textarea { min-height: 100px; resize: vertical; }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  margin-top: 12px;
}

/* Login screen */
.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 24px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}
.login h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login .subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
}

/* Toast */
.toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  z-index: 300;
  animation: slideDown 0.2s;
  font-size: 14px;
  text-align: center;
}
.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--danger); }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Toggle switch */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 15px; }
.toggle {
  width: 50px;
  height: 30px;
  background: var(--surface-2);
  border-radius: 15px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(20px); }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.totals-bar {
  display: flex;
  justify-content: space-around;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.totals-item { text-align: center; }
.totals-num { font-size: 16px; font-weight: 600; color: var(--text); display: block; }
.totals-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }
