/* ==========================================
   Food Log System - Design System CSS
   Phase 03: UI Design Exploration (8 Options) + Phase 05/06 Manual Editor
   Rules: Pure White BG, Black & White dominant, Accent points, NO EMOJIS, NO Dark mode
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Sarabun:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-muted: #4b5563;
  --border-main: #111827;
  --border-width: 2px;
  
  --accent-color: #2563eb;
  --shadow-offset: 4px 4px 0px #111827;
  --shadow-offset-hover: 6px 6px 0px #111827;
  --shadow-offset-active: 2px 2px 0px #111827;
  
  --font-heading: 'Outfit', 'Sarabun', sans-serif;
  --font-body: 'Sarabun', 'Outfit', sans-serif;
}

html {
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navigation */
.sketch-header {
  background-color: var(--bg-main);
  border-bottom: var(--border-width) solid var(--border-main);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sketch-icon-btn {
  background: var(--bg-main);
  border: var(--border-width) solid var(--border-main);
  box-shadow: var(--shadow-offset);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease-in-out;
  min-width: 44px;
  min-height: 44px;
}

.sketch-icon-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-offset-hover);
}

.sketch-icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-offset-active);
}

.icon-svg {
  width: 22px;
  height: 22px;
  stroke: var(--text-main);
  stroke-width: 2.2;
  fill: none;
}

/* Sidebar Drawer */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(17, 24, 39, 0.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background-color: var(--bg-main);
  border-right: var(--border-width) solid var(--border-main);
  box-shadow: 6px 0px 0px #111827;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-drawer.active {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px dashed var(--border-main);
  padding-bottom: 1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: var(--border-width) solid var(--border-main);
  border-radius: 6px;
  background: var(--bg-main);
  box-shadow: 3px 3px 0px #111827;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 600;
  min-height: 44px;
  transition: all 0.15s ease;
}

.nav-item:hover, .nav-item.active {
  background: #eff6ff;
  border-color: var(--accent-color);
  box-shadow: 4px 4px 0px var(--accent-color);
  color: var(--accent-color);
}

/* Main Layout */
.main-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.page-title-block {
  border-bottom: 2px solid var(--border-main);
  padding-bottom: 1rem;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* Buttons & Inputs (Pencil Sketch Style) */
.sketch-btn {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border: var(--border-width) solid var(--border-main);
  border-radius: 4px;
  background: var(--bg-main);
  color: var(--text-main);
  box-shadow: var(--shadow-offset);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  transition: all 0.15s ease;
}

.sketch-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-offset-hover);
}

.sketch-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-offset-active);
}

.sketch-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.sketch-btn-primary {
  background: var(--accent-color);
  color: #ffffff;
}

.sketch-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border: var(--border-width) solid var(--border-main);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-main);
  box-shadow: 2px 2px 0px #111827;
}

.sketch-badge.status-ok {
  background: #dcfce7;
  border-color: #166534;
  color: #166534;
  box-shadow: 2px 2px 0px #166534;
}

.sketch-card {
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-main);
  box-shadow: var(--shadow-offset);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sketch-input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
  border: var(--border-width) solid var(--border-main);
  border-radius: 6px;
  background: var(--bg-main);
  color: var(--text-main);
  box-shadow: 3px 3px 0px #111827;
  outline: none;
  width: 100%;
  min-height: 44px;
}

.sketch-code-block {
  background: #f8fafc;
  border: var(--border-width) solid var(--border-main);
  border-radius: 6px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  box-shadow: 3px 3px 0px #111827;
  overflow-x: auto;
}

/* Drag & Drop Zone */
.sketch-dropzone {
  border: 3px dashed var(--border-main);
  border-radius: 8px;
  background: #f8fafc;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 4px 4px 0px #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sketch-dropzone:hover, .sketch-dropzone.dragover {
  background: #eff6ff;
  border-color: var(--accent-color);
  box-shadow: 6px 6px 0px var(--accent-color);
}

/* Progress Bar */
.sketch-progress-track {
  height: 16px;
  background: #f3f4f6;
  border: var(--border-width) solid var(--border-main);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 2px 2px 0px #111827;
}

.sketch-progress-fill {
  height: 100%;
  background: var(--accent-color);
  transition: width 0.3s ease;
}

/* Timeline Overview Bar */
.timeline-overview-card {
  background: #f8fafc;
  border: 2px solid #111827;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  box-shadow: 3px 3px 0px #111827;
  margin-bottom: 0.75rem;
}

.timeline-bar-track {
  min-height: 42px;
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 4px;
  box-shadow: 2px 2px 0px #111827;
  display: flex;
  align-items: center;
  padding: 0.35rem 0.5rem;
  overflow-x: auto;
  gap: 0.4rem;
}

.timeline-group-block {
  height: 30px;
  border: 1.5px solid #111827;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 1.5px 1.5px 0px #111827;
  white-space: nowrap;
  background: #eff6ff;
  color: #2563eb;
  transition: all 0.15s ease;
}

.timeline-group-block:hover {
  filter: brightness(0.96);
}

.timeline-split-handle {
  background: #ffffff;
  border: 1.5px solid #111827;
  color: #111827;
  box-shadow: 1.5px 1.5px 0px #111827;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 28px;
}

.timeline-split-handle:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #ef4444;
  box-shadow: 2px 2px 0px #b91c1c;
}

/* Grouping Preview Cards & Drag Target Highlight */
@keyframes flashBorder {
  0% { border-color: #2563eb; box-shadow: 0 0 16px rgba(37, 99, 235, 0.8); transform: scale(1.005); }
  50% { border-color: #2563eb; box-shadow: 0 0 20px rgba(37, 99, 235, 0.9); }
  100% { border-color: #111827; box-shadow: 5px 5px 0px #111827; transform: scale(1); }
}

.flash-highlight {
  animation: flashBorder 1.5s ease-out;
}

.sketch-group-card {
  border: var(--border-width) solid var(--border-main);
  box-shadow: 5px 5px 0px #111827;
  border-radius: 4px;
  padding: 1.25rem;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sketch-group-card.drag-target {
  background: #eff6ff !important;
  border-color: var(--accent-color) !important;
  box-shadow: 7px 7px 0px var(--accent-color) !important;
}

.sketch-group-card.group-selected {
  border-color: #d97706 !important;
  box-shadow: 6px 6px 0px #d97706 !important;
  background: #fffbe6 !important;
}

.preview-thumb-grid {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  overflow-x: auto;
  min-height: 110px;
  padding: 0.4rem;
  border: 2px dashed transparent;
  border-radius: 4px;
  transition: border-color 0.15s ease;
}

.sketch-group-card.drag-target .preview-thumb-grid {
  border-color: var(--accent-color);
}

.preview-thumb-item {
  border: 2px solid #111827;
  border-radius: 4px;
  overflow: hidden;
  background: #f8fafc;
  box-shadow: 2.5px 2.5px 0px #111827;
  position: relative;
  cursor: grab;
  user-select: none;
  min-width: 120px;
  width: 120px;
  height: 100px;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.preview-thumb-item:active {
  cursor: grabbing;
}

.preview-thumb-item.dragging {
  opacity: 0.4;
  border-style: dashed;
}

.preview-thumb-item.multiselect-selected {
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 3px #93c5fd, 3px 3px 0px var(--accent-color) !important;
}

/* Drop Insertion Line (Blue Bar) */
.preview-thumb-item.drop-left {
  border-left: 5px solid var(--accent-color) !important;
  transform: translateX(4px);
}

.preview-thumb-item.drop-right {
  border-right: 5px solid var(--accent-color) !important;
  transform: translateX(-4px);
}

.preview-thumb-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

/* Split Button Bar between Thumbnails */
.sketch-split-btn {
  background: #ffffff;
  border: 2px solid #111827;
  box-shadow: 2px 2px 0px #111827;
  border-radius: 4px;
  color: #111827;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3rem 0.4rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.sketch-split-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #ef4444;
  box-shadow: 3px 3px 0px #b91c1c;
}

/* Multi-select Checkbox Badge */
.thumb-checkbox {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent-color);
  cursor: pointer;
  z-index: 6;
}

/* Order Badge (#1, #2, ...) */
.preview-thumb-order-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #111827;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  border: 1px solid #ffffff;
  box-shadow: 1px 1px 0px #111827;
  z-index: 5;
}

/* Reorder Bar Controls (Move Left / Move Right) */
.preview-thumb-reorder-bar {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  z-index: 5;
}

.thumb-move-btn {
  background: #ffffff;
  color: #111827;
  border: 1.5px solid #111827;
  box-shadow: 1.5px 1.5px 0px #111827;
  border-radius: 3px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.1s ease;
}

.thumb-move-btn:hover:not(:disabled) {
  background: #eff6ff;
  color: var(--accent-color);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.thumb-move-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.preview-thumb-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(17, 24, 39, 0.88);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.3rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Web-Native Custom Modal (Pencil Sketch Option 1 Style) */
.sketch-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.sketch-modal-card {
  background: #ffffff;
  border: 2px solid #111827;
  box-shadow: 5px 5px 0px #111827;
  border-radius: 4px;
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: sketchPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes sketchPop {
  0% { transform: scale(0.9) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.sketch-modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  border-bottom: 2px dashed #111827;
  padding-bottom: 0.5rem;
}

.sketch-modal-message {
  font-size: 0.95rem;
  color: #111827;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-line;
}

.sketch-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.sketch-modal-actions button {
  min-height: 44px;
  min-width: 100px;
}

/* View Containers Layout */
.view-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

/* OPTION 1 Theme Elements */
.opt1-card {
  background: #ffffff;
  border: 2px solid #111827;
  box-shadow: 5px 5px 0px #111827;
  border-radius: 2px;
  padding: 1.25rem;
}

.opt1-tag {
  border: 2px solid #111827;
  box-shadow: 2px 2px 0px #111827;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 2px;
  background: #ffffff;
}

.wf-meal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Floating Sketch Context Menu (Pencil Sketch Style) */
.sketch-context-menu {
  position: fixed;
  z-index: 9999;
  background: #ffffff;
  border: 2px solid #111827;
  border-radius: 6px;
  box-shadow: 4px 4px 0px #111827;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 200px;
  animation: menuPopIn 0.15s ease-out;
}

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

.context-menu-item {
  background: #ffffff;
  border: 1.5px solid transparent;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
  min-height: 44px; /* Upgraded to >= 44px touch target standard */
}

.context-menu-item:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}



/* Pencil Sketch Custom Checkbox Design Standard */
input[type="checkbox"].sketch-checkbox,
input[type="checkbox"].filter-favorite-checkbox,
.group-select-checkbox,
.photo-select-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border: 2px solid #111827;
  border-radius: 4px;
  background-color: #ffffff;
  box-shadow: 2px 2px 0px #111827;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: none;
  transition: all 0.15s ease;
  vertical-align: middle;
}

input[type="checkbox"].sketch-checkbox:checked,
input[type="checkbox"].filter-favorite-checkbox:checked,
.group-select-checkbox:checked,
.photo-select-checkbox:checked {
  background-color: #2563eb;
  border-color: #111827;
  box-shadow: 2px 2px 0px #111827;
}

input[type="checkbox"].sketch-checkbox:checked::after,
input[type="checkbox"].filter-favorite-checkbox:checked::after,
.group-select-checkbox:checked::after,
.photo-select-checkbox:checked::after {
  content: '';
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

input[type="checkbox"].sketch-checkbox:hover,
input[type="checkbox"].filter-favorite-checkbox:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px #111827;
}

/* =====================================================================
   Mobile Responsive Media Queries (Pencil Sketch Optimization)
   ===================================================================== */
@media (max-width: 640px) {
  .sketch-header {
    padding: 0.6rem 0.85rem;
  }

  .brand-title {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
  }

  .main-content {
    padding: 1rem 0.75rem;
    gap: 1.25rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .page-subtitle {
    font-size: 0.82rem;
  }

  /* Calendar View Responsive */
  .sketch-calendar-view {
    padding: 0.75rem !important;
    overflow-x: auto;
  }

  .calendar-header {
    flex-direction: row;
    gap: 0.3rem;
  }

  .calendar-title {
    font-size: 0.85rem !important;
    text-align: center;
    line-height: 1.2;
  }

  .calendar-grid {
    gap: 0.2rem !important;
  }

  .calendar-day-cell {
    min-width: 0 !important;
    min-height: 40px !important;
    padding: 0.2rem 0.05rem !important;
  }

  .day-number {
    font-size: 0.72rem !important;
  }

  .calendar-today-badge {
    font-size: 0.48rem !important;
    padding: 0 0.1rem !important;
  }

  .meal-indicator {
    font-size: 0.58rem !important;
    padding: 0 0.15rem !important;
  }

  /* Toolbar & Controls Responsive */
  #home-sort-filter-bar {
    flex-direction: column;
    align-items: stretch !important;
    padding: 0.75rem !important;
    gap: 0.6rem !important;
  }

  #home-sort-filter-bar > div {
    width: 100% !important;
  }

  #home-sort-select, #home-date-from, #home-date-to {
    width: 100% !important;
  }

  #home-clear-filters-btn {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: 0.25rem !important;
  }

  /* Grid Layouts */
  .wf-meal-grid {
    grid-template-columns: 1fr;
  }

  .editor-toolbar {
    flex-direction: column;
    align-items: stretch !important;
  }

  .editor-toolbar button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  #home-summary-stats {
    flex-direction: row;
    padding: 0.6rem 0.4rem !important;
    gap: 0.35rem !important;
  }

  #home-summary-stats > div {
    min-width: 0 !important;
  }

  #home-summary-stats div[style*="font-size: 1.5rem"] {
    font-size: 1.15rem !important;
  }

  .sketch-dropzone {
    padding: 1.25rem 0.75rem;
  }

  .sketch-modal-card {
    padding: 1rem;
    width: 94%;
  }
}

