﻿/* ═══════════════════════════════════════════════════════════════
   Moodiz V12 — Design Tokens
════════════════════════════════════════════════════════════════ */
:root {
  /* Surfaces */
  --c-bg:         #f5f2ed;
  --c-surface:    #eeebe5;
  --c-surface-2:  #e6e2da;

  /* Borders & text */
  --c-border:     #d9d4cc;
  --c-text:       #2a2723;
  --c-text-2:     rgba(42,39,35,.52);

  /* Primary action */
  --c-primary:    #4f8a69;
  --c-primary-fg: #ffffff;
  --c-primary-h:  #3d7055;

  /* Semantic */
  --c-error:      #a03828;
  --c-error-bg:   #f9ecea;

  /* Geometry */
  --r:            14px;
  --r-sm:         8px;
  --pad:          18px;
  --shadow:       0 1px 3px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.06);
  --font:         "Noto Sans", system-ui, -apple-system, sans-serif;

  /* Legacy aliases */
  --md-primary:         var(--c-primary);
  --md-surface:         var(--c-surface);
  --md-surface-variant: var(--c-bg);
  --md-outline:         var(--c-border);
  --md-text:            var(--c-text);
  --md-error:           var(--c-error);
  --md-error-bg:        var(--c-error-bg);
  --md-radius:          var(--r);
  --md-padding:         var(--pad);
  --md-font:            var(--font);
}

:root.dark {
  --c-bg:         #181b19;
  --c-surface:    #1f2420;
  --c-surface-2:  #252c27;
  --c-border:     #2e3530;
  --c-text:       #d4d8d2;
  --c-text-2:     rgba(200,205,198,.5);
  --c-primary:    #6aa882;
  --c-primary-fg: #ffffff;
  --c-primary-h:  #80b895;
  --c-error:      #e07060;
  --c-error-bg:   #3a1a15;

  --md-primary:         var(--c-primary);
  --md-surface:         var(--c-surface);
  --md-surface-variant: var(--c-bg);
  --md-outline:         var(--c-border);
  --md-text:            var(--c-text);
  --md-error:           var(--c-error);
  --md-error-bg:        var(--c-error-bg);
}

/* ═══════════════════════════════════════════════════════════════
   Reset / Base
════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════
   Layout
════════════════════════════════════════════════════════════════ */
.container { width: 100%; background: none; }

.app-container {
  margin-top: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 12px 28px;
}

/* ═══════════════════════════════════════════════════════════════
   App Bar
════════════════════════════════════════════════════════════════ */
#app-bar { display: none; }

.app-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 800px;
  height: 56px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 0 0 var(--r) var(--r);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.4px;
}

.welcome-text {
  font-size: 13px;
  color: var(--c-text-2);
  flex: 1;
  text-align: center;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-actions button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  border-radius: var(--r-sm);
  line-height: 1;
  color: var(--c-text);
  transition: background .15s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-actions button:hover { background: var(--c-surface-2); }

/* ═══════════════════════════════════════════════════════════════
   Cards
════════════════════════════════════════════════════════════════ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: var(--pad);
  width: 100%;
  max-width: 800px;
  box-shadow: var(--shadow);
}

.card-primary {
  border-color: rgba(79,138,105,.35);
}
.dark .card-primary {
  border-color: rgba(106,168,130,.3);
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.1px;
}

@media (max-width: 599px) {
  .card { max-width: 100%; margin: 0; }
  .app-container { padding: 0 10px 24px; gap: 12px; }
}
@media (min-width: 600px)  { .card { max-width: 600px; } }
@media (min-width: 1024px) { .card { max-width: 800px; } }

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

.card-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-2);
  padding: 0;
  margin: 0;
  border-radius: 50%;
  transition: background .15s;
  flex-shrink: 0;
}

.card-toggle:hover { background: var(--c-surface-2); }

.card-toggle::before {
  content: "▾";
  font-size: 14px;
  display: inline-block;
  transition: transform .3s ease;
}

.card-toggle.open::before { transform: rotate(180deg); }

/* ═══════════════════════════════════════════════════════════════
   Buttons
════════════════════════════════════════════════════════════════ */
button {
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--r-sm);
  border: none;
  transition: background .15s, opacity .15s;
}

/* Default filled button (login, etc.) */
button:not(.outlined-btn):not(.card-toggle):not(.mood-face-btn):not(.chart-tab):not(.app-actions button):not(.menu-close):not(.theme-toggle-btn):not(.menu-action-btn):not(.btn-primary) {
  background: var(--c-primary);
  color: var(--c-primary-fg);
  padding: 10px 20px;
  margin: 8px 0;
}

button:not(.outlined-btn):not(.card-toggle):not(.mood-face-btn):not(.chart-tab):not(.app-actions button):not(.menu-close):not(.theme-toggle-btn):not(.menu-action-btn):not(.btn-primary):hover {
  background: var(--c-primary-h);
}

.outlined-btn {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text);
  padding: 9px 16px;
  margin: 8px 0;
}
.outlined-btn:hover { background: var(--c-surface-2); }

/* Primary CTA */
.btn-primary {
  background: var(--c-primary);
  color: var(--c-primary-fg);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  width: 100%;
  margin-top: 14px;
  letter-spacing: 0.2px;
  border-radius: var(--r);
}
.btn-primary:hover:not(:disabled) { background: var(--c-primary-h); }
.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: var(--c-border);
  color: var(--c-text-2);
}

/* ═══════════════════════════════════════════════════════════════
   Inputs
════════════════════════════════════════════════════════════════ */
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  width: 100%;
  padding: 10px 12px;
  margin: 6px 0;
  font-family: var(--font);
  font-size: 14px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text);
  outline: none;
  transition: border-color .15s;
}

input:focus, textarea:focus { border-color: var(--c-primary); }
textarea { resize: vertical; min-height: 72px; }

/* ═══════════════════════════════════════════════════════════════
   Login hero
════════════════════════════════════════════════════════════════ */
.login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 12px auto 18px;
  width: 100%;
  max-width: 600px;
}

.login-logo {
  width: 55%;
  max-width: 220px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.12));
}

.login-tagline {
  font-size: 16px;
  color: var(--c-text-2);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   Quick Mood Card — two-step UX
════════════════════════════════════════════════════════════════ */
.mood-scale-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.mood-face-btn {
  flex: 1;
  background: none;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  padding: 4px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mood-face-btn:hover {
  border-color: var(--c-border);
  transform: scale(1.06);
}

.mood-face-btn.selected {
  border-color: var(--c-primary);
  background: rgba(79,138,105,.09);
}
.dark .mood-face-btn.selected {
  background: rgba(106,168,130,.12);
}

.mood-scale {
  width: 100%;
  max-width: 50px;
  height: auto;
  display: block;
  pointer-events: none;
}

/* Hidden until face selected */
.mood-detail {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .35s ease, opacity .28s ease;
}

.mood-detail.visible {
  max-height: 240px;
  opacity: 1;
}

.slider-wrap { display: block; margin: 14px 0 4px; }

.slider-label {
  text-align: center;
  font-size: 13px;
  color: var(--c-text-2);
  margin-bottom: 10px;
}

/* Slider */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--track-color, var(--c-border));
  outline: none;
  border: none;
  margin: 0;
  padding: 0;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--track-color, var(--c-border));
}
input[type=range]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--track-color, var(--c-border));
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  margin-top: -8px;
}
input[type=range]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-primary);
  cursor: pointer;
  border: 2px solid #fff;
}

/* ═══════════════════════════════════════════════════════════════
   Chart Section — tabs + panels
════════════════════════════════════════════════════════════════ */
.chart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--c-border);
  padding-bottom: 10px;
}

.chart-tab {
  flex: 1;
  background: none;
  border: 1px solid transparent;
  color: var(--c-text-2);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  margin: 0;
}

.chart-tab:hover {
  color: var(--c-text);
  background: var(--c-surface-2);
}

.chart-tab.active {
  background: var(--c-primary);
  color: var(--c-primary-fg);
}

.chart-panel[hidden] { display: none !important; }

.chart-wrap {
  position: relative;
  height: 260px;
}

.chart-wrap-sm {
  position: relative;
  height: 200px;
}

canvas { display: block; width: 100% !important; height: 100% !important; }

/* Heatmap scrollable container */
.heatmap-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.heatmap-svg { display: block; min-width: 600px; }

/* ═══════════════════════════════════════════════════════════════
   Error Box
════════════════════════════════════════════════════════════════ */
.error-box {
  border: 1px solid var(--c-error);
  background: var(--c-error-bg);
  padding: 12px 14px;
  margin: 12px 0 0;
  border-radius: var(--r-sm);
}

.error-box strong {
  display: block;
  color: var(--c-error);
  margin-bottom: 4px;
  font-size: 14px;
}

.error-box div { font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════
   Latest Entries — card-style list
════════════════════════════════════════════════════════════════ */
.mood-entry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
}

.mood-entry-item:last-child { border-bottom: none; }

.mood-entry-chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.mood-entry-meta { flex: 1; min-width: 0; }

.mood-entry-date {
  font-size: 12px;
  color: var(--c-text-2);
  line-height: 1.4;
}

.mood-entry-note {
  font-size: 13px;
  color: var(--c-text);
  margin-top: 3px;
  word-break: break-word;
}

/* Table fallback */
table, th, td { color: var(--c-text); }
#mood-list table { border-collapse: collapse; width: 100%; }
#mood-list th, #mood-list td {
  border: 1px solid var(--c-border);
  padding: 6px 8px;
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   Splash
════════════════════════════════════════════════════════════════ */
#splash {
  background: var(--c-bg);
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.6s ease;
}

#splash.fade-out { opacity: 0; pointer-events: none; }
#splash img { width: 120px; max-width: 40vw; }

/* ═══════════════════════════════════════════════════════════════
   Misc
════════════════════════════════════════════════════════════════ */
.small-text {
  font-size: 13px;
  color: var(--c-text-2);
  margin-top: 8px;
}

pre#login-out {
  font-family: var(--font);
  font-size: 13px;
  color: var(--c-error);
  white-space: pre-wrap;
  margin: 6px 0 0;
}

/* Initially hidden — shown by JS after login */
#mood-section,
#chart-section,
#bubble-section,
#entries-section {
  display: none;
}
