/*
 * Mobile-first responsive stylesheet for the interactive worksheets app
 *
 * The layout emphasises a clean, distraction-free workspace on small screens
 * with a slide-out panel for selecting worksheets. On larger screens (>900px),
 * the panel retains a narrower width but is still hidden by default; a menu
 * button toggles it open. Colours and typography reflect the warm, hand-drawn
 * aesthetic of James Roberts Mental Wellness.
 */

/* Root colour palette. Adjust these values to tweak the overall theme. */
:root {
  --bg-color: #f6f0d6;
  --panel-bg: #fdf8ea;
  --header-bg: #425C35;
  --accent-color: #d85a06;
  --text-color: #333333;
  --input-border: rgba(0, 0, 0, 0.2);
  --header-height: 70px;
}

/* Utility wrappers (legacy T-button support; safe to keep) */
.time-input-wrapper {
  display: flex;
  align-items: center;
}
.timestamp-btn {
  margin-left: 0.4rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border: none;
  border-radius: 0.3rem;
  background: var(--header-bg);
  color: #fff;
  cursor: pointer;
}
.timestamp-btn:hover { background: #344b2d; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.45;
  /* Space for the fixed header at the top (desktop/tablet) */
  padding-top: var(--header-height);
}

/* ------------------------------- Header --------------------------------- */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  min-height: var(--header-height);
  height: auto;
  background: #ffffff;
  border-bottom: 2px solid #eee;
  z-index: 1000;
}

/* Three zones: left button, centered logo, right (if any) */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 1rem;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.logo { flex-grow: 1; display: flex; justify-content: center; }
.logo img { height: 50px; width: auto; display: block; }

.nav {
  display: flex;
  gap: 1.6rem;
  margin-left: 2rem;
  align-items: center;
  font-family: 'Gloria Hallelujah', cursive;
  flex-wrap: wrap;
}
.nav a {
  text-decoration: none;
  color: #131313;
  font-weight: 900;
  font-size: 1.05rem;
  position: relative;
  white-space: nowrap;
}
.nav a:hover,
.nav a.active { border-bottom: 3px solid var(--accent-color); }

/* Primary buttons (worksheet menu / nav toggle) */
.menu-toggle,
.worksheet-btn,
.nav-toggle {
  background-color: var(--header-bg);
  color: #ffffff;
  border: none;
  padding: 0.5rem 0.8rem;
  border-radius: 0.3rem;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.menu-toggle:hover,
.worksheet-btn:hover,
.nav-toggle:hover { background-color: #344b2d; }

/* ------------------------- Distraction-Free Toggle ----------------------- */
/* Floating round icon (desktop defaults) */
#distraction-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1050;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background-color: var(--header-bg);
  color: #fff;
  cursor: pointer;
  transition: bottom 0.4s ease, right 0.4s ease, top 0.4s ease, transform 0.4s ease;
}
#distraction-btn:hover { background-color: #344b2d; }

/* On phones: keep on right edge, float mid-screen vertically (away from hamburger) */
@media (max-width: 700px) {
  #distraction-btn {
    right: 1rem;     /* right edge */
    bottom: 40vh;    /* around mid-screen */
    top: auto;       /* ensure no top anchoring on mobile */
    transform: none; /* no translate adjustments */
  }
}

/* ---------------------------- Header Extras ----------------------------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-wrap: wrap;
}
/* If you keep call/crisis buttons elsewhere, these styles remain harmless */
.call-btn, .crisis-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Roboto Slab', serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: 0.3rem;
  color: #ffffff;
}
.call-btn svg, .crisis-btn svg {
  width: 0.9em; height: 0.9em; fill: currentColor; flex-shrink: 0;
}
.call-btn { background-color: var(--header-bg); }
.call-btn:hover { background-color: #344b2d; }
.crisis-btn { background-color: var(--accent-color); }
.crisis-btn:hover { background-color: #b44b05; }

/* ---------------------------- Worksheet panel --------------------------- */
.worksheet-panel {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 90%; max-width: 320px;
  background: var(--panel-bg);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.3);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 1100;
  overflow-y: auto;
  padding: 1rem 1rem 2rem;
}
.worksheet-panel.open { transform: translateX(0); }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.panel-header h2 {
  margin: 0;
  font-family: 'Gloria Hallelujah', cursive;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--header-bg);
}
.panel-header button {
  background: none; border: none; font-size: 1.5rem; color: var(--header-bg); cursor: pointer;
}

.category-section { margin-top: 1rem; }
.category-section h3 {
  margin: 0.4rem 0;
  font-family: 'Gloria Hallelujah', cursive;
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--header-bg);
}
.worksheet-link {
  width: 100%; text-align: left;
  padding: 0.5rem 0.7rem; margin: 0.2rem 0;
  background: #ffffff; border: 2px solid var(--input-border); border-radius: 0.3rem;
  font-family: 'Roboto Slab', serif; font-size: 1rem; color: var(--text-color);
  cursor: pointer; transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.worksheet-link:hover { background: var(--accent-color); color: #ffffff; border-color: var(--accent-color); }

/* Larger screens: fixed width panel */
@media (min-width: 900px) { .worksheet-panel { width: 300px; max-width: 300px; } }

/* ---------------------------- Workspace area ---------------------------- */
#workspace {
  padding: 1rem 1rem 5rem;
  transition: margin-left 0.3s ease;
}

.welcome {
  font-family: 'Gloria Hallelujah', cursive;
  font-size: 1.3rem;
  margin-top: 2rem;
  text-align: center;
  color: var(--header-bg);
}

/* Worksheet header inside the workspace */
.worksheet-header {
  display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.5rem;
}
.worksheet-header img { height: 45px; width: auto; }
.worksheet-title {
  font-family: 'Gloria Hallelujah', cursive;
  font-weight: 900;
  font-size: 1.4rem;
  color: var(--header-bg);
  margin: 0;
}
.worksheet-description {
  font-family: 'Roboto Slab', serif; font-size: 1rem; margin-bottom: 1rem; color: var(--text-color);
}

/* Module container */
.module {
  background: #ffffff;
  border: 2px solid var(--input-border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.module-label {
  font-family: 'Gloria Hallelujah', cursive;
  font-weight: 900;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--header-bg);
}
.module-info {
  font-family: 'Roboto Slab', serif;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: #555;
}

/* Input module */
.module input[type="text"],
.module input[type="number"],
.module input[type="date"],
.module textarea {
  width: 100%;
  padding: 0.5rem;
  font-family: 'Roboto Slab', serif;
  font-size: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 0.3rem;
  background: #fafafa;
  resize: vertical;
}
.module textarea { min-height: 4rem; }

/* Slider module */
.slider-row { display: flex; align-items: center; gap: 0.8rem; }
.slider-row input[type="range"] { flex: 1; }
.slider-value {
  font-family: 'Roboto Slab', serif;
  font-weight: 700;
  color: var(--header-bg);
}

/* Table module */
.module table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
}
.module table th, .module table td {
  border: 1px solid var(--input-border);
  padding: 0.4rem 0.5rem;
  text-align: left;
  font-family: 'Roboto Slab', serif;
  font-size: 0.9rem;
}
.module table th {
  background: var(--header-bg);
  color: #ffffff;
  font-weight: 700;
}
.module table td input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.9rem;
}
.add-row-btn {
  background: var(--accent-color);
  color: #fff;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 0.3rem;
  font-family: 'Roboto Slab', serif;
  font-size: 0.9rem;
  cursor: pointer;
}
.add-row-btn:hover { background: #b44b05; }

/* Date/time picker icon inside inputs */
.input-with-icon { position: relative; display: inline-block; width: 100%; }
.input-with-icon input { width: 100%; padding-right: 2rem; }
.input-with-icon .date-btn {
  position: absolute; right: 0.4rem; top: 50%;
  transform: translateY(-50%);
  border: none; background: transparent; cursor: pointer; font-size: 1rem; color: #666;
}

/* Range slider wrapper and value bubble */
.range-wrap { position: relative; width: 100%; }
.range-output {
  position: absolute; top: -1.6rem; right: 0;
  font-size: 0.8rem; color: var(--text-color);
}

/* Mini action dock for distraction mode */
.action-dock {
  position: fixed; right: 4rem; bottom: 1rem; z-index: 2000;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #d6d6d6;
  border-radius: 999px;
  padding: 0.4rem 0.6rem;
  display: flex; gap: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
body:not(.distraction-mode) .action-dock { display: none; }
.action-dock button {
  background: var(--header-bg); color: #fff; border: none;
  padding: 0.4rem 0.8rem; border-radius: 999px;
  font-family: 'Roboto Slab', serif; font-size: 0.9rem; cursor: pointer;
}
.action-dock button:hover { background: #344b2d; }

/* Drag and drop module */
.drag-drop-container { display: flex; flex-direction: column; gap: 0.7rem; }
.drag-items { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.draggable {
  padding: 0.4rem 0.6rem;
  background: #fff0dc;
  border: 1px dashed var(--accent-color);
  border-radius: 0.3rem;
  font-family: 'Roboto Slab', serif; font-size: 0.9rem;
  cursor: grab;
}
.dropzones { display: flex; flex-direction: column; gap: 0.8rem; }
.dropzone {
  min-height: 2.4rem; padding: 0.5rem; background: #fafafa;
  border: 2px dashed var(--input-border); border-radius: 0.3rem;
  font-family: 'Roboto Slab', serif; font-size: 0.9rem; color: var(--text-color);
}
.dropzone.over { border-color: var(--accent-color); background: #fff8ee; }

/* Action buttons container */
.action-buttons {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 1rem;
  padding: 0.6rem; background: var(--panel-bg); border-top: 2px solid #eee; z-index: 1000;
}
.action-buttons button {
  background: var(--header-bg); color: #fff; border: none;
  padding: 0.6rem 1rem; border-radius: 0.4rem;
  font-family: 'Roboto Slab', serif; font-size: 0.9rem; cursor: pointer;
}
.action-buttons button:hover { background: #344b2d; }

/* Progress bar */
.progress-container {
  position: fixed; left: 0; right: 0; bottom: 3rem; /* above action buttons */
  height: 4px; background: rgba(0, 0, 0, 0.1); z-index: 999;
}
.progress-bar { width: 0; height: 100%; background: var(--accent-color); transition: width 0.3s ease; }

/* Distraction-free mode: hide site chrome (toggle stays visible) */
body.distraction-mode header,
body.distraction-mode .worksheet-panel,
body.distraction-mode .nav-panel,
body.distraction-mode .action-buttons,
body.distraction-mode .progress-container,
body.distraction-mode .nav-toggle,
body.distraction-mode .worksheet-btn { display: none !important; }

body.distraction-mode #workspace { padding-top: 1rem; }

/* ---------------------- Responsive header adjustments ------------------- */
@media (max-width: 700px) {
  /* On phones, let content flow; header becomes static height */
  header { position: static; height: auto; }
  body { padding-top: 0; }

  /* Hide top nav and header extras on small screens */
  .nav, .header-actions { display: none; }

  /* Keep worksheet and nav toggles visible on phones */
  .worksheet-btn, .nav-toggle { display: flex; }
}

@media (min-width: 701px) {
  .nav, .header-actions { display: flex; }
  .nav-toggle { display: none; }   /* hide mobile nav toggle on wide screens */
  header { position: fixed; }
  body { padding-top: var(--header-height); }
}

/* --------------------------- Slide-out Nav (R) -------------------------- */
.nav-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 85%; max-width: 320px;
  background: var(--panel-bg);
  box-shadow: -2px 0 6px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1150;
  padding: 1rem;
  overflow-y: auto;
}
.nav-panel.open { transform: translateX(0); }

.nav-panel-header { display: flex; justify-content: flex-end; }
.nav-panel-header button {
  background: none; border: none; font-size: 1.6rem; color: var(--header-bg); cursor: pointer;
}
.nav-panel-links {
  display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem;
}
.nav-panel-links a {
  font-family: 'Gloria Hallelujah', cursive;
  font-weight: 900; text-decoration: none;
  color: var(--header-bg); font-size: 1.2rem;
}
.nav-panel-links a:hover { color: var(--accent-color); }
.nav-panel-actions { margin-top: 2rem; display: flex; flex-direction: column; gap: 0.8rem; }

/* ----------------------- Responsive Table Patterns ---------------------- */
.table-wrap { width: 100%; overflow-x: auto; }

/* Stacked row-cards under 760px */
@media (max-width: 760px) {
  table.responsive {
    border-collapse: separate; border-spacing: 0; width: 100%;
  }
  table.responsive thead { display: none; }
  table.responsive tbody tr {
    display: block; border: 1px solid #d6d6d6; border-radius: 10px;
    padding: 0.6rem 0.75rem; margin-bottom: 0.75rem; background: #ffffff;
  }
  table.responsive tbody td {
    display: grid; grid-template-columns: 42% 1fr; gap: 0.5rem; align-items: center;
    padding: 0.3rem 0; border: none;
  }
  table.responsive tbody td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--header-bg); font-size: 0.92rem;
  }
  table.responsive input,
  table.responsive textarea,
  table.responsive select { width: 100%; min-height: 2.25rem; }
}

/* Hide optional columns on very narrow screens */
@media (max-width: 400px) {
  td[data-priority="low"],
  td[data-priority="low"]::before { display: none; }
}
