/* ============================================================
   Leafy Track — Plant Care Tracking App
   Mobile-first stylesheet (360x740 target viewport)
   ============================================================ */

/* ============================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  --primary:        #4CAF50;
  --primary-dark:   #388E3C;
  --primary-light:  #E8F5E9;
  --secondary:      #81C784;
  --accent:         #FFEB3B;
  --accent-dark:    #F9A825;
  --background:     #F5F5F5;
  --surface:        #FFFFFF;
  --text-primary:   #212121;
  --text-secondary: #757575;
  --text-hint:      #9E9E9E;
  --divider:        #E0E0E0;
  --error:          #F44336;
  --error-light:    #FFEBEE;
  --on-primary:     #FFFFFF;
  --on-accent:      #333333;

  --shadow-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
  --shadow-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
  --shadow-top: 0 -2px 8px rgba(0,0,0,0.10);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

  --topbar-height: 56px;
  --bottomnav-height: 56px;

  --font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

ul, ol { list-style: none; }

/* ============================================================
   3. APP SHELL
   ============================================================ */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--background);
  max-width: 480px;
  margin: 0 auto;
}

/* Screen management */
.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  z-index: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  z-index: 1;
}

.screen-content {
  padding: 16px;
  padding-top: 8px;
  padding-bottom: calc(var(--bottomnav-height) + 16px);
}

.screen-content::-webkit-scrollbar { display: none; }

/* ============================================================
   4. APP BAR (per-screen, generated by JS)
   ============================================================ */
.app-bar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 4px;
  z-index: 100;
  box-shadow: var(--shadow-2);
  user-select: none;
  flex-shrink: 0;
}

.app-title {
  flex: 1;
  text-align: center;
  color: var(--on-primary);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon Button */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--on-primary);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  font-size: 18px;
}

.icon-btn:hover { background: rgba(255,255,255,0.12); }
.icon-btn:active { background: rgba(255,255,255,0.24); }

.icon-btn .icon {
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
}

/* ============================================================
   5. BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: var(--bottomnav-height);
  background: var(--surface);
  box-shadow: var(--shadow-top);
  display: flex;
  align-items: stretch;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  cursor: pointer;
  position: relative;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  overflow: hidden;
  border: none;
  background: transparent;
  padding: 6px 0 4px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.nav-item.active .nav-icon {
  transform: scale(1.15);
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.4px;
  line-height: 1;
  text-transform: uppercase;
}

/* ============================================================
   6. SIDE DRAWER
   ============================================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.drawer-overlay.show {
  opacity: 1;
  visibility: visible;
}

.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--surface);
  z-index: 310;
  transform: translateX(-100%);
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-3);
  overflow-y: auto;
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
}

.drawer-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-emoji {
  font-size: 32px;
}

.drawer-title {
  color: var(--on-primary);
  font-size: 18px;
  font-weight: 700;
}

.drawer-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  margin-top: 2px;
}

.drawer-header .icon-btn {
  color: rgba(255,255,255,0.9);
}

.drawer-nav {
  padding: 8px 0;
  flex: 1;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
  min-height: 48px;
}

.drawer-item:hover { background: rgba(0,0,0,0.04); }
.drawer-item:active { background: rgba(0,0,0,0.08); }

.drawer-item-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.drawer-item-label {
  flex: 1;
}

.drawer-divider {
  height: 1px;
  background: var(--divider);
  margin: 8px 16px;
}

.drawer-footer {
  padding: 16px 24px;
  color: var(--text-hint);
  font-size: 12px;
}

.drawer-footer p { margin-bottom: 2px; }

/* ============================================================
   7. CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 16px;
  margin-bottom: 12px;
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   8. STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   9. BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  min-height: 44px;
  position: relative;
  overflow: hidden;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-primary.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  min-height: 32px;
  border-radius: 6px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  min-height: 32px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  min-height: 44px;
}

.btn-secondary:hover { background: #C8E6C9; }

.btn-text {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.btn-text:hover { background: rgba(76,175,80,0.08); }

.btn-retry {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

/* ============================================================
   10. FAB (Floating Action Button)
   ============================================================ */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--bottomnav-height) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  box-shadow: 0 4px 20px rgba(255, 235, 59, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  z-index: 98;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  max-width: 480px;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(255, 235, 59, 0.55);
}

.fab:active {
  transform: scale(0.95);
}

.fab.fab-hidden {
  transform: scale(0) !important;
  opacity: 0;
  pointer-events: none;
}

.fab-icon {
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

/* ============================================================
   11. BOTTOM SHEET
   ============================================================ */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.sheet-overlay.show {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-3);
  z-index: 410;
  transform: translateY(100%);
  transition: transform var(--transition);
  overflow-y: auto;
  padding: 0 20px 24px;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin: 10px auto 8px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 16px;
}

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

.sheet-close-btn {
  color: var(--text-secondary);
  font-size: 18px;
}

.sheet-body {
  padding-bottom: 16px;
}

/* ============================================================
   12. FORMS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-error {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
  min-height: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 8px;
}

.form-actions .btn-primary {
  flex: 1;
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23757575'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ============================================================
   13. SEARCH BAR
   ============================================================ */
.search-bar-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
  gap: 10px;
}

.search-icon {
  font-size: 16px;
  color: var(--text-hint);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-hint);
}

/* ============================================================
   14. PLANT CARDS
   ============================================================ */

/* Dashboard plant list item */
.plant-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.plant-list-item:last-child { border-bottom: none; }

.plant-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.plant-info {
  flex: 1;
  min-width: 0;
}

.plant-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plant-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.plant-water-status {
  text-align: right;
  flex-shrink: 0;
}

.water-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.water-badge.watered {
  background: #E3F2FD;
  color: #1565C0;
}

.water-badge.needs-water {
  background: #FFF3E0;
  color: #E65100;
}

.plant-date {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 2px;
}

/* Plant Log full card */
.plant-card {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 14px;
  margin-bottom: 10px;
  align-items: flex-start;
}

.plant-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.plant-card-body {
  flex: 1;
  min-width: 0;
}

.plant-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.plant-card-species {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.plant-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.meta-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.water-chip {
  background: #E3F2FD;
  color: #1565C0;
}

.fert-chip {
  background: #FFF3E0;
  color: #E65100;
}

.plant-card-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.plant-card-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.plant-card-actions .icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  color: var(--text-secondary);
  font-size: 16px;
}

.plant-card-actions .icon-btn:hover {
  background: rgba(0,0,0,0.06);
}

/* ============================================================
   15. JOURNAL CARDS
   ============================================================ */
.journal-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 14px;
  margin-bottom: 10px;
}

.journal-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.journal-card-mood {
  font-size: 28px;
  flex-shrink: 0;
}

.journal-card-meta {
  flex: 1;
  min-width: 0;
}

.journal-card-plant {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.journal-card-date {
  font-size: 11px;
  color: var(--text-hint);
}

.journal-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.journal-card-actions .icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  color: var(--text-secondary);
  font-size: 14px;
}

.journal-card-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Dashboard mini journal items */
.journal-item-sm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}

.journal-item-sm:last-child { border-bottom: none; }

.journal-mood {
  font-size: 20px;
  flex-shrink: 0;
}

.journal-info { flex: 1; min-width: 0; }

.journal-plant {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.journal-preview {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-date {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 2px;
}

/* ============================================================
   16. MOOD PICKER
   ============================================================ */
.mood-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mood-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--divider);
  background: var(--surface);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.mood-btn:hover { border-color: var(--secondary); }

.mood-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.1);
}

/* ============================================================
   17. EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.empty-state-sm {
  text-align: center;
  padding: 16px 8px;
}

.empty-state-sm p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* ============================================================
   18. QUICK ACTIONS
   ============================================================ */
.quick-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 16px;
}

.quick-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  transition: transform var(--transition-fast);
  min-height: 44px;
  position: relative;
  overflow: hidden;
}

.quick-action-btn:active { transform: scale(0.95); }

.qa-icon {
  font-size: 24px;
}

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

.calendar-nav .icon-btn {
  color: var(--text-primary);
  font-size: 18px;
}

.calendar-month-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.cal-day-name {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
  padding: 4px 0;
  text-transform: uppercase;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  position: relative;
  cursor: default;
}

.cal-cell.empty { visibility: hidden; }

.cal-cell.today {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  border-radius: 50%;
}

.cal-day-num {
  font-size: 13px;
  line-height: 1;
}

.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 2px;
  height: 5px;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 11px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.today-legend {
  background: var(--primary);
}

/* Events */
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}

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

.event-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-info { flex: 1; }

.event-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.event-type {
  font-size: 11px;
  color: var(--text-secondary);
}

.event-date {
  font-size: 12px;
  color: var(--text-hint);
  flex-shrink: 0;
}

/* ============================================================
   20. PLACEHOLDER TEXT
   ============================================================ */
.placeholder-text {
  font-size: 13px;
  color: var(--text-hint);
  font-style: italic;
  padding: 8px 0;
}

/* ============================================================
   21. AI FEATURES
   ============================================================ */
.ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.ai-loading {
  padding: 12px 0;
}

.ai-shimmer {
  height: 14px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  border-radius: 7px;
  margin-bottom: 8px;
  animation: shimmer 1.5s infinite;
}

.ai-shimmer-short { width: 60%; }
.ai-shimmer-medium { width: 80%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ai-result {
  padding: 8px 0;
}

.ai-result.fade-in {
  animation: fadeIn 0.3s ease;
}

.ai-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-result-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
}

.ai-result-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--primary-light);
  padding: 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.ai-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  color: var(--error);
  font-size: 13px;
}

.ai-error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--error-light);
  color: var(--error);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================
   22. CHARTS
   ============================================================ */
.chart-container {
  width: 100%;
  min-height: 160px;
  padding: 8px 0;
}

.chart-container svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-empty {
  text-align: center;
  font-size: 13px;
  color: var(--text-hint);
  font-style: italic;
  padding: 24px 0;
}

/* Horizontal bar chart */
.h-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.h-bar-label {
  width: 70px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.h-bar-track {
  flex: 1;
  height: 16px;
  background: #f0f0f0;
  border-radius: 8px;
  overflow: hidden;
}

.h-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s ease;
}

.h-bar-value {
  width: 30px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  flex-shrink: 0;
}

/* Donut chart */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-label {
  color: var(--text-primary);
}

.donut-legend-pct {
  color: var(--text-hint);
  font-weight: 600;
}

/* Progress bar */
.progress-bar-wrap {
  margin-bottom: 10px;
}

.progress-bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.progress-bar-track {
  height: 10px;
  background: #f0f0f0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 2px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}

.progress-bar-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}

/* Adherence */
.adherence-item {
  margin-bottom: 14px;
}

.adherence-label {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
}

.adherence-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 2px;
}

/* ============================================================
   23. CHAT
   ============================================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height) - var(--bottomnav-height));
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 80px;
}

.chat-messages::-webkit-scrollbar { display: none; }

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.chat-welcome h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.chat-welcome p {
  font-size: 13px;
}

.chat-bubble-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: flex-end;
}

.chat-bubble-wrap.user-wrap {
  justify-content: flex-end;
}

.chat-bubble-wrap.assistant-wrap {
  justify-content: flex-start;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble.user-bubble {
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant-bubble {
  background: var(--surface);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-1);
}

.chat-bubble.error-bubble {
  background: var(--error-light);
  color: var(--error);
}

.bubble-content { word-break: break-word; }

.bubble-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.loading-bubble {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-hint);
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-input-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--divider);
  align-items: center;
  z-index: 60;
  max-width: 480px;
  margin: 0 auto;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--background);
  outline: none;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-input::placeholder {
  color: var(--text-hint);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.chat-send-btn:active { background: var(--primary-dark); }

/* ============================================================
   24. SNACKBAR
   ============================================================ */
.snackbar {
  position: fixed;
  bottom: calc(var(--bottomnav-height) + 12px);
  left: 16px;
  right: 16px;
  max-width: 400px;
  margin: 0 auto;
  background: #323232;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 500;
  transform: translateY(100px);
  opacity: 0;
  transition: transform var(--transition), opacity var(--transition);
  box-shadow: var(--shadow-2);
}

.snackbar.show {
  transform: translateY(0);
  opacity: 1;
}

.snackbar.hide {
  transform: translateY(100px);
  opacity: 0;
}

.snackbar-message {
  flex: 1;
}

.snackbar-action {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 8px;
  border: none;
  background: none;
  cursor: pointer;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ============================================================
   25. CONFIRM DIALOG
   ============================================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.dialog-overlay.show { opacity: 1; }
.dialog-overlay.fade-out { opacity: 0; }

.dialog-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-3);
  text-align: center;
}

.dialog-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.dialog-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-dialog {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: background var(--transition-fast);
}

.btn-cancel {
  background: #f0f0f0;
  color: var(--text-primary);
}

.btn-cancel:hover { background: #e0e0e0; }

.btn-confirm {
  background: var(--error);
  color: #fff;
}

.btn-confirm:hover { background: #D32F2F; }

/* ============================================================
   26. RIPPLE EFFECT
   ============================================================ */
@keyframes ripple-anim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple-anim 0.6s linear;
}

/* ============================================================
   27. ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   28. UTILITY
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   29. SVG IN CHARTS
   ============================================================ */
.chart-container svg text {
  font-family: var(--font-family);
}

.chart-bar {
  transition: height 0.5s ease, y 0.5s ease;
}
