/* =============================================
   ChronicLog — Style Sheet
   © Stephanie Adams
   ============================================= */

:root {
  --navy:       #0d2137;
  --navy-mid:   #143352;
  --navy-light: #1d4470;
  --teal:       #1a8c8c;
  --teal-light: #22b5b5;
  --amber:      #e8a030;
  --amber-light:#f5bf5c;
  --coral:      #e05555;
  --green:      #2daa6e;
  --text:       #e8f0f8;
  --text-muted: #7fa3c4;
  --text-dim:   #4d7a9e;
  --card-bg:    #112840;
  --card-border:#1d3f5e;
  --input-bg:   #0d2137;
  --input-border:#1d4470;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.35);
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-x: hidden;
}

/* Background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(26,140,140,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(232,160,48,0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---- TYPOGRAPHY ---- */
h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.4rem; color: var(--text); }
h3 { font-size: 1.05rem; color: var(--teal-light); margin-bottom: 0.75rem; }
em { font-style: italic; color: var(--teal-light); }
label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; display: block; margin-bottom: 0.35rem; letter-spacing: 0.03em; text-transform: uppercase; }
p { line-height: 1.6; }

/* ---- HEADER ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,33,55,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  padding: env(safe-area-inset-top, 0) 0 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  max-width: 700px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.3rem;
  color: var(--teal-light);
  line-height: 1;
}

.logo-text {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 0.25rem;
}

.icon-btn {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--teal-light); border-color: var(--teal); background: rgba(26,140,140,0.1); }

/* ---- TAB NAV ---- */
.tab-nav {
  display: flex;
  background: rgba(13,33,55,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 57px;
  z-index: 99;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.4rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  position: relative;
}
.tab-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.tab-btn:hover { color: var(--text-muted); }
.tab-btn.active {
  color: var(--teal-light);
  border-bottom-color: var(--teal-light);
}

/* ---- MAIN ---- */
.app-main {
  max-width: 700px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
  z-index: 1;
}

/* ---- TAB PANELS ---- */
.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }

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

/* ---- SECTION HEADER ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.date-chip {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
}

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  margin-top: -0.35rem;
}

.form-card { border-color: var(--teal); }

/* ---- QUICK STATS ---- */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  text-align: center;
}
.stat-card .stat-val {
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  color: var(--teal-light);
  line-height: 1;
  display: block;
}
.stat-card .stat-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
  display: block;
}

/* ---- MOOD / DAILY CHECK ---- */
.mood-card h3 { margin-bottom: 1rem; }

.pain-scale { margin-bottom: 0.9rem; }
.scale-btns {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.35rem;
}
.scale-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: var(--navy-mid);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.scale-btn:hover { border-color: var(--teal); color: var(--teal-light); }
.scale-btn.active {
  background: var(--teal);
  border-color: var(--teal-light);
  color: white;
  font-weight: 700;
}
.pain-label { font-size: 0.8rem; color: var(--text-muted); }

.mood-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.mood-row label {
  text-transform: none;
  letter-spacing: 0;
  min-width: 120px;
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.emoji-row { display: flex; gap: 0.4rem; }
.emoji-btn {
  font-size: 1.3rem;
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 3px;
  cursor: pointer;
  transition: var(--transition);
  opacity: 0.5;
}
.emoji-btn:hover { opacity: 1; transform: scale(1.15); }
.emoji-btn.active { opacity: 1; border-color: var(--teal); background: rgba(26,140,140,0.15); }

.inline-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0.45rem 0.65rem;
  width: 80px;
}

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--teal);
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237fa3c4' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.form-group option { background: var(--navy-mid); }

.mt-sm { margin-top: 0.5rem; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ---- SEVERITY BUTTONS ---- */
.severity-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.sev-btn {
  padding: 0.35rem 0.75rem;
  background: var(--navy-mid);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.sev-btn:hover { border-color: var(--teal); color: var(--teal-light); }
.sev-btn.active {
  background: var(--teal);
  border-color: var(--teal-light);
  color: white;
}
.sev-btn.flare.active {
  background: linear-gradient(135deg, #c0392b, #e67e22);
  border-color: #e74c3c;
}

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  flex: 1;
}
.btn-primary:hover { background: var(--teal-light); }

.btn-ghost {
  background: none;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.btn-add {
  background: rgba(26,140,140,0.15);
  border: 1px solid var(--teal);
  border-radius: var(--radius-sm);
  color: var(--teal-light);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-add:hover { background: rgba(26,140,140,0.3); }

.btn-ghost-sm {
  background: none;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  margin-top: 0.5rem;
}
.btn-ghost-sm:hover { border-color: var(--teal); color: var(--teal-light); }

.btn-small {
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

/* ---- ENTRY LIST ---- */
.entry-list { display: flex; flex-direction: column; gap: 0.5rem; }

.entry-item {
  background: var(--navy-mid);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  position: relative;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.entry-item .entry-title {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.entry-item .entry-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.entry-item .entry-meta .tag {
  background: rgba(26,140,140,0.15);
  border: 1px solid rgba(26,140,140,0.3);
  color: var(--teal-light);
  padding: 0.1rem 0.45rem;
  border-radius: 12px;
  font-size: 0.7rem;
}
.entry-item .entry-meta .tag.flare {
  background: rgba(224,85,85,0.15);
  border-color: rgba(224,85,85,0.4);
  color: #ff8a80;
}
.entry-item .entry-meta .tag.missed {
  background: rgba(224,85,85,0.15);
  border-color: rgba(224,85,85,0.4);
  color: #ff8a80;
}
.entry-item .entry-meta .tag.taken {
  background: rgba(45,170,110,0.15);
  border-color: rgba(45,170,110,0.3);
  color: #5ddb9e;
}

.entry-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: var(--transition);
}
.entry-delete:hover { color: var(--coral); background: rgba(224,85,85,0.1); }

.empty-state {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

/* ---- SUBSECTION LABEL ---- */
.subsection-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 1rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.subsection-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-border);
}

/* ---- MORE GRID ---- */
.more-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
.full-width { grid-column: 1 / -1; }

/* ---- TAG LIST ---- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  min-height: 32px;
}

.tag-item {
  background: rgba(26,140,140,0.15);
  border: 1px solid rgba(26,140,140,0.3);
  color: var(--teal-light);
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.tag-item button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  line-height: 1;
}
.tag-item button:hover { color: var(--coral); }

.inline-add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.inline-add input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
}
.inline-add input:focus { outline: none; border-color: var(--teal); }

/* ---- DATA ACTIONS ---- */
.data-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}
.data-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--navy-mid);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}
.data-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.data-btn:hover { border-color: var(--teal); color: var(--teal-light); }
.data-btn.danger:hover { border-color: var(--coral); color: var(--coral); }

.data-note {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---- CONTACT FORM MINI ---- */
.form-card.mini {
  padding: 0.75rem;
  margin-top: 0.5rem;
}
.form-card.mini input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.4rem;
  display: block;
}
.form-card.mini input:focus { outline: none; border-color: var(--teal); }
.btn-primary.sm, .btn-ghost.sm {
  font-size: 0.8rem;
  padding: 0.45rem 0.8rem;
}

.entry-list.compact .entry-item { padding: 0.55rem 0.75rem; }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy-light);
  border: 1px solid var(--teal);
  color: var(--text);
  padding: 0.65rem 1.2rem;
  border-radius: 30px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- SUPPORT FOOTER ---- */
.support-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--card-border);
  position: relative;
  z-index: 1;
}
.support-footer p {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.support-btn {
  display: inline-block;
  background: linear-gradient(135deg, #e8a030, #f5bf5c);
  color: #0d2137;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 30px;
  text-decoration: none;
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(232,160,48,0.3);
}
.support-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(232,160,48,0.45);
}
.footer-credit {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.75rem !important;
}

@media print {
  .support-footer { display: none; }
}
@media print {
  body { background: white !important; color: black !important; }
  .app-header, .tab-nav, .icon-btn, .btn-primary, .btn-ghost, .btn-add, .btn-small, .entry-delete { display: none !important; }
  .tab-panel { display: block !important; }
  .card { background: white !important; border: 1px solid #ccc !important; break-inside: avoid; }
  :root {
    --text: #111;
    --text-muted: #555;
    --teal-light: #0a6b6b;
    --card-bg: white;
  }
  .print-header { display: block !important; }
}

.print-header {
  display: none;
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 540px) {
  .quick-stats { grid-template-columns: repeat(4, 1fr); }
  .data-actions { flex-direction: row; flex-wrap: wrap; }
  .data-btn { flex: 1; }
}
