/* =====================================
   🌸 My Cycles - Pink Theme Styles
   ===================================== */

:root {
  --pink-50: #fdf2f8;
  --pink-100: #fce7f3;
  --pink-200: #fbcfe8;
  --pink-300: #f9a8d4;
  --pink-400: #f472b6;
  --pink-500: #ec4899;
  --pink-600: #db2777;
  --pink-700: #be185d;
  --pink-800: #9d174d;
  --pink-900: #831843;

  --rose-100: #ffe4e6;
  --rose-300: #fda4af;
  --rose-500: #f43f5e;

  --bg: var(--pink-50);
  --card-bg: #ffffff;
  --text: #4a1942;
  --text-muted: #8b5a7a;
  --border: var(--pink-200);
  --shadow: 0 2px 12px rgba(219, 39, 119, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 32px;
}

/* ---- Header ---- */
header {
  text-align: center;
  padding: 24px 0 16px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--pink-700);
}

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

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--pink-100);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab.active {
  background: white;
  color: var(--pink-700);
  box-shadow: var(--shadow);
}

.tab:hover:not(.active) {
  color: var(--pink-600);
  background: rgba(255,255,255,0.5);
}

.tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-content.active {
  display: block;
}

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

/* ---- Loading ---- */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.loading.hidden { display: none; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--pink-200);
  border-top-color: var(--pink-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

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

/* ---- Pill Grid ---- */
.pill-header {
  text-align: center;
  margin-bottom: 8px;
}

.pill-header h2 { font-size: 20px; }

.pill-pack-info {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0;
  font-size: 14px;
  color: var(--text-muted);
}

.pill-today-label {
  background: var(--pink-100);
  padding: 2px 12px;
  border-radius: 20px;
  font-weight: 500;
  color: var(--pink-700);
}

.pill-cycle-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pill-nav-btn {
  background: var(--pink-100);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--pink-700);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.pill-nav-btn:hover { background: var(--pink-200); }
.pill-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.pill-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.pill {
  aspect-ratio: 1;
  border: 2px solid var(--pink-200);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  color: var(--text-muted);
  position: relative;
  user-select: none;
}

.pill .pill-num {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.pill .pill-date {
  font-size: 8px;
  opacity: 0.6;
  margin-top: 1px;
}

.pill.taken {
  background: var(--pink-200);
  border-color: var(--pink-400);
  color: var(--pink-800);
}

.pill.taken .pill-num::after {
  content: ' ✓';
  font-size: 10px;
}

.pill.today {
  border-color: var(--pink-500);
  box-shadow: 0 0 0 2px var(--pink-300);
}

.pill.missed {
  background: var(--rose-100);
  border-color: var(--rose-300);
  color: var(--rose-500);
}

.pill.future {
  opacity: 0.5;
}

.pill:hover:not(.future) {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(219,39,119,0.2);
}

.pill.placebo {
  border-style: dashed;
  border-color: var(--pink-300);
  opacity: 0.6;
}

/* ---- Progress Bar ---- */
.pill-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--pink-100);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink-400), var(--pink-500));
  border-radius: 10px;
  transition: width 0.4s ease;
}

.pill-progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--pink-700);
  min-width: 36px;
}

/* ---- Stats ---- */
.pill-stats, .cycle-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.stat-card {
  background: white;
  border: 1px solid var(--pink-200);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--pink-600);
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Buttons ---- */
.btn-primary, .btn-secondary, .btn-danger, .btn-danger-outline {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--pink-500);
  color: white;
}
.btn-primary:hover { background: var(--pink-600); }

.btn-secondary {
  background: var(--pink-100);
  color: var(--pink-700);
}
.btn-secondary:hover { background: var(--pink-200); }

.btn-danger {
  background: var(--rose-500);
  color: white;
}
.btn-danger:hover { background: #e11d48; }

.btn-danger-outline {
  background: transparent;
  border: 2px solid var(--rose-300);
  color: var(--rose-500);
}
.btn-danger-outline:hover { background: var(--rose-100); }

/* ---- Period Section ---- */
.period-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.period-actions button {
  flex: 1;
  min-width: 100px;
}

.current-period-info {
  background: var(--rose-100);
  border: 1px solid var(--rose-300);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 14px;
  color: var(--rose-500);
  font-weight: 500;
  text-align: center;
}

.period-list {
  margin-top: 8px;
}

.period-item {
  background: white;
  border: 1px solid var(--pink-200);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.period-item .period-dates {
  color: var(--text-muted);
  font-size: 12px;
}

.period-item .period-badge {
  background: var(--rose-100);
  color: var(--rose-500);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.period-item .period-delete {
  background: none;
  border: none;
  color: var(--rose-300);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.15s;
  margin-left: 8px;
}

.period-item .period-delete:hover {
  color: var(--rose-500);
  background: var(--rose-100);
}

/* ---- Manual Period Entry ---- */
/* ---- Confirmation Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(74, 25, 66, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(74, 25, 66, 0.25);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--pink-800);
  margin-bottom: 8px;
}

.modal-body {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions button {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-btn-cancel {
  background: var(--pink-100);
  color: var(--pink-700);
}
.modal-btn-cancel:hover { background: var(--pink-200); }

.modal-btn-danger {
  background: var(--rose-500);
  color: white;
}
.modal-btn-danger:hover { background: #e11d48; }

/* ---- Calendar ---- */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-nav-btn {
  background: var(--pink-100);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--pink-700);
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
}
.cal-nav-btn:hover { background: var(--pink-200); }

.cal-month-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--pink-700);
}

.cal-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.period-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--pink-100);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
}

.period-list-section {
  margin: 16px 0;
}

.period-list-section h3 {
  font-size: 15px;
  color: var(--pink-700);
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 12px;
}

.cal-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border-radius: 50%;
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.cal-day:not(.other-month):hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--pink-300);
  z-index: 1;
}

.cal-day.other-month {
  color: #ddd;
}

.cal-day.today-cal {
  font-weight: 800;
  color: var(--pink-900);
  box-shadow: inset 0 0 0 2px var(--pink-600);
}

.cal-day.today-cal.period-day,
.cal-day.today-cal.pill-day,
.cal-day.today-cal.both-day {
  box-shadow: inset 0 0 0 2px #fbbf24, inset 0 0 0 4px white;
}

.cal-day.period-day {
  background: #e11d48;
  color: white;
  font-weight: 700;
}

.cal-day.period-day:not(.other-month):hover {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 0 4px #e11d48;
  transform: scale(1.1);
}

.cal-day.pill-day {
  background: #7c3aed;
  color: white;
  font-weight: 600;
}

.cal-day.both-day {
  background: linear-gradient(135deg, #e11d48 50%, #7c3aed 50%);
  background-size: 100% 100%;
  color: white;
  font-weight: 700;
  border: 2px solid #fbbf24;
}

.calendar-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.period-dot { background: #e11d48; }
.pill-dot { background: #7c3aed; }
.both-dot {
  background: linear-gradient(135deg, #e11d48 50%, #7c3aed 50%);
  border: 1.5px solid #fbbf24;
}

.cycle-summary h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--pink-700);
}

/* ---- Settings ---- */
.settings-group {
  background: white;
  border: 1px solid var(--pink-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.settings-group h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--pink-700);
}

.input-group {
  margin-bottom: 12px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="time"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--pink-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}

.input-group input:focus {
  border-color: var(--pink-400);
  box-shadow: 0 0 0 3px var(--pink-100);
}

.status-msg {
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}
.status-msg.connected { color: #10b981; }
.status-msg.error { color: var(--rose-500); }

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.toggle-label input { display: none; }

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--pink-200);
  border-radius: 24px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-label input:checked + .toggle-slider {
  background: var(--pink-500);
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.reminder-time-group {
  margin-top: 10px;
}

#import-section textarea {
  width: 100%;
  height: 80px;
  padding: 8px;
  border: 1px solid var(--pink-200);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  margin-bottom: 8px;
}

.footer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.hidden { display: none; }

/* ---- Responsive ---- */
@media (max-width: 380px) {
  .pill-grid { gap: 5px; }
  .pill { font-size: 10px; }
  .pill .pill-num { font-size: 12px; }
  .tabs { gap: 3px; }
  .tab { font-size: 11px; padding: 8px 4px; }
}
