/* ==========================================================================
   Apple HIG Components for GymLog
   Cards, Segmented Controls, Progressive Set Logger, Sheets, Rest Timer
   ========================================================================== */

/* --- Apple Cards & Containers --- */
.apple-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.apple-card-elevated {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
}

.apple-card:active {
  transform: scale(0.995);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Apple Segmented Controls --- */
.apple-segmented-control {
  display: flex;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-pill);
  position: relative;
  user-select: none;
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.segmented-option {
  flex: 1;
  text-align: center;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
}

.segmented-option.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* --- Apple Buttons --- */
.apple-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: none;
  font-family: inherit;
  text-decoration: none;
}

.apple-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.apple-btn-primary {
  background: var(--apple-blue);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}

.apple-btn-success {
  background: var(--apple-green);
  color: #000000;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(48, 209, 88, 0.35);
}

.apple-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.apple-btn-secondary:hover {
  background: var(--bg-elevated);
}

.apple-btn-danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--apple-red);
  border: 1px solid rgba(255, 69, 58, 0.3);
}

.apple-btn-danger:active {
  background: var(--apple-red);
  color: #FFFFFF;
}

.apple-btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.apple-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.apple-btn-icon .svg-icon {
  width: 16px;
  height: 16px;
}

.apple-btn-block {
  width: 100%;
}

/* --- Form Controls & Inputs --- */
.apple-input-group {
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

.apple-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.apple-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="time"].apple-input,
input[type="date"].apple-input {
  max-width: 100%;
  box-sizing: border-box;
  display: block;
  -webkit-appearance: none;
  min-height: 44px;
}

.apple-input:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.apple-input::placeholder {
  color: var(--text-tertiary);
}

.apple-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 16px;
}

.apple-search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  width: 100%;
}

/* --- Progressive Workout Set Table & Rows --- */
.exercise-log-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.exercise-log-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.exercise-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.exercise-meta-badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  display: inline-block;
  margin-top: 4px;
}

.sets-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.sets-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 6px 8px;
  text-align: center;
}

.sets-table th:first-child {
  text-align: left;
  width: 44px;
}

.sets-table th:nth-child(2) {
  text-align: center;
  width: 70px;
}

.sets-table th:last-child {
  text-align: right;
  width: 44px;
}

.set-row {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.15s ease;
}

.set-row.completed {
  background-color: rgba(48, 209, 88, 0.08);
}

.set-row td {
  padding: 8px 6px;
  vertical-align: middle;
  text-align: center;
}

.set-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.set-row.completed .set-num-badge {
  background: rgba(48, 209, 88, 0.25);
  color: var(--apple-green);
}

.prev-val {
  font-size: 13px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.set-input {
  width: 68px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 4px;
  text-align: center;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-mono);
  outline: none;
  transition: all 0.15s ease;
}

.set-input:focus {
  border-color: var(--apple-blue);
  background: var(--bg-elevated);
}

.set-row.completed .set-input {
  border-color: transparent;
  background: transparent;
  color: var(--text-primary);
}

.btn-check-set {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-check-set:hover {
  border-color: var(--apple-green);
  color: var(--apple-green);
}

.btn-check-set.active {
  background: var(--apple-green);
  border-color: var(--apple-green);
  color: #000000;
  transform: scale(1.05);
}

.add-set-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-medium);
  color: var(--apple-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.add-set-btn:hover {
  background: var(--bg-elevated);
}

/* --- Floating Rest Timer Pill (Apple Dynamic Island / Live Activity style) --- */
.floating-timer-bar {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
  width: calc(100% - 32px);
  max-width: 480px;
  pointer-events: none;
}

.floating-timer-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.timer-pill-content {
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-lg), 0 0 20px rgba(10, 132, 255, 0.2);
}

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

.timer-ring-container {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg-ring {
  width: 38px;
  height: 38px;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  stroke: var(--bg-tertiary);
}

.timer-ring-progress {
  stroke: var(--apple-blue);
  transition: stroke-dashoffset 0.5s linear;
}

.timer-ring-icon {
  position: absolute;
  font-size: 14px;
  color: var(--apple-blue);
}

.timer-info-text {
  display: flex;
  flex-direction: column;
}

.timer-countdown {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.timer-label {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.timer-btn:active {
  transform: scale(0.9);
}

/* --- Apple Frosted Bottom Tab Bar --- */
.apple-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  background: var(--bg-glass);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 6px 12px var(--safe-bottom);
  z-index: 45;
  max-width: var(--max-width);
  margin: 0 auto;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 0;
  transition: all 0.18s ease;
}

.tab-item:active {
  transform: scale(0.92);
}

.tab-item.active {
  color: var(--apple-blue);
}

.tab-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* --- Apple Modal Bottom Sheet --- */
.apple-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.apple-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.apple-modal-sheet {
  background: var(--bg-secondary);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border: 1px solid var(--border-medium);
  border-bottom: none;
  width: 100%;
  max-width: var(--max-width);
  max-height: 88vh;
  overflow-y: auto;
  padding: 12px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

.apple-modal-backdrop.open .apple-modal-sheet {
  transform: translateY(0);
}

.sheet-drag-handle {
  width: 36px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.3);
  margin: 0 auto 16px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 700;
}

.btn-sheet-close {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* --- Habit Streak & Notification Cards --- */
.streak-hero-card {
  background: linear-gradient(135deg, rgba(255, 159, 10, 0.15), rgba(191, 90, 242, 0.1));
  border: 1px solid rgba(255, 159, 10, 0.25);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.streak-number {
  font-size: 38px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--apple-orange);
  line-height: 1;
}

.streak-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- Calendar Heatmap Grid --- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.calendar-day-cell {
  aspect-ratio: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.calendar-day-cell.today {
  border-color: var(--apple-blue);
  color: var(--text-primary);
  font-weight: 700;
}

.calendar-day-cell.has-workout {
  background: rgba(48, 209, 88, 0.2);
  border-color: var(--apple-green);
  color: var(--apple-green);
  font-weight: 700;
}

.calendar-workout-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--apple-green);
  margin-top: 2px;
}

/* --- Filter Chips Row --- */
.chip-filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.chip-filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-chip.active {
  background: var(--apple-blue);
  border-color: var(--apple-blue);
  color: #FFFFFF;
}

/* --- iOS & Android Install Banner / Sheet --- */
.install-guide-sheet {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-medium);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.install-step-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-primary);
}

.install-step-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--apple-blue);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
