/* Habit Tracker - dual monthly (landscape) / weekly (portrait) views */

.container-wrapper {
  max-width: 1150px;
  margin: 0 auto 80px auto;
  display: flex;
  justify-content: center;
}

/* Shared container base */
.container {
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Monthly = A4 landscape */
.container-monthly {
  width: 1150px;
  aspect-ratio: 1.4142 / 1;
  padding: 36px 44px;
}

/* Weekly = A4 portrait */
.container-weekly {
  width: 900px;
  aspect-ratio: 1 / 1.4142;
  padding: 44px 56px;
}

/* Only the active view shows; both stay in the DOM for SEO */
body.view-monthly .container-weekly {
  display: none;
}

body.view-weekly .container-monthly {
  display: none;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.container-monthly .header {
  margin-bottom: 22px;
}

.container-weekly .header {
  margin-bottom: 34px;
}

.header .planner-title {
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 2px;
  margin: 0;
  color: #1a1a1a;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-field label {
  font-size: 14px;
  letter-spacing: 1px;
}

.date-field input {
  border: none;
  border-bottom: 1px solid #1a1a1a;
  padding: 5px;
  font-size: 14px;
  width: 200px;
  outline: none;
  background: transparent;
}

/* Habit grid */
.habit-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.habit-header-row {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.habit-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.habit-row {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 0;
}

/* Habit name column */
.habit-name-cell {
  flex-shrink: 0;
  box-sizing: border-box;
  padding-right: 14px;
}

.container-monthly .habit-name-cell {
  width: 210px;
}

.container-weekly .habit-name-cell {
  width: 260px;
}

.habit-name-head {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #1a1a1a;
}

.habit-input {
  border: none;
  border-bottom: 1px solid #1a1a1a;
  padding: 0 0 4px 0;
  font-size: 14px;
  outline: none;
  background: transparent;
  width: 100%;
  color: #1a1a1a;
  box-sizing: border-box;
}

.habit-input:focus {
  border-bottom-color: #1a1a1a;
}

/* Day columns */
.habit-days {
  flex: 1;
  display: grid;
  min-width: 0;
}

.container-monthly .habit-days {
  grid-template-columns: repeat(31, 1fr);
}

.container-weekly .habit-days {
  grid-template-columns: repeat(7, 1fr);
}

.day-col {
  text-align: center;
  font-weight: 600;
  color: #1a1a1a;
}

.container-monthly .day-col {
  font-size: 11px;
}

.container-weekly .day-col {
  font-size: 13px;
}

.day-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Checkboxes - circle is the default here (habit-tracker convention) */
input[type="checkbox"] {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid #1a1a1a;
  background-color: white;
  position: relative;
  border-radius: 3px;
  transition: all 0.2s ease;
}

.container-monthly input[type="checkbox"] {
  width: 15px;
  height: 15px;
}

.container-weekly input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

input[type="checkbox"].circular {
  border-radius: 50%;
}

input[type="checkbox"]:checked {
  background-color: #082845;
  border-color: #082845;
}

input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  color: white;
  font-size: 10px;
  font-weight: bold;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.container-weekly input[type="checkbox"]:checked::after {
  font-size: 12px;
}

/* Controls */
.controls {
  margin: 0 auto;
  padding: 30px 40px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.view-monthly .controls {
  max-width: 1150px;
}

body.view-weekly .controls {
  max-width: 900px;
}

.toggle-group {
  display: flex;
  gap: 24px;
  align-items: center;
}

.view-toggle,
.checkbox-style-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
}

.toggle-button {
  display: flex;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
  padding: 0;
  cursor: pointer;
}

.toggle-option {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
  color: #6b7280;
  user-select: none;
}

.toggle-option.active {
  background-color: #ffffff;
  color: #1a1a1a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.print-btn,
.save-pdf-btn {
  color: white;
  border: none;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
  background-color: #082845;
}

.print-btn:hover,
.save-pdf-btn:hover {
  background-color: #0a3a5c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(8, 40, 69, 0.3);
}

/* Tablet & Mobile Scaling (JS drives the transform on the active container) */
@media (max-width: 1200px) {
  .container-wrapper {
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    overflow: visible;
  }

  .container {
    transform-origin: top center;
    flex-shrink: 0;
    aspect-ratio: auto;
  }
}

/* Tablet Controls Layout */
@media (max-width: 940px) and (min-width: 769px) {
  .controls {
    flex-direction: column;
    gap: 16px;
    padding: 24px 40px;
    align-items: stretch;
  }

  .toggle-group {
    flex-direction: row;
    justify-content: flex-start;
    gap: 32px;
  }

  .view-toggle,
  .checkbox-style-toggle {
    justify-content: flex-start;
  }

  .action-buttons {
    flex-direction: row;
    gap: 12px;
  }

  .print-btn,
  .save-pdf-btn {
    flex: 1;
    padding: 14px 24px;
  }
}

/* Mobile Controls Layout */
@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    gap: 20px;
    padding: 24px 16px;
    align-items: stretch;
  }

  .toggle-group {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .view-toggle,
  .checkbox-style-toggle {
    justify-content: space-between;
  }

  .action-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .print-btn,
  .save-pdf-btn {
    width: 100%;
    padding: 14px 24px;
  }

  .habit-input,
  .date-field input {
    font-size: 16px;
  }
}

/* Related Planners Section */
.related-planners {
  padding: 60px 20px;
  background-color: #f9fafb;
}

.related-container {
  max-width: 900px;
  margin: 0 auto;
}

.related-title {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 32px;
  color: #1a1a1a;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.related-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.related-card:hover {
  border-color: #082845;
  box-shadow: 0 4px 12px rgba(8, 40, 69, 0.1);
  transform: translateY(-2px);
}

.related-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: #082845;
  margin: 0 0 8px 0;
}

.related-card p {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .related-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .related-planners {
    padding: 40px 16px;
  }
}

/* Print Styles - @page size (landscape/portrait) is set by JS per active view */
@media print {
  body {
    padding: 0;
    margin: 0;
    background-color: white;
  }

  .container-wrapper {
    width: auto !important;
    height: auto !important;
    display: block;
    overflow: visible;
    margin: 0;
    max-width: none;
  }

  .container {
    transform: none !important;
    width: 100% !important;
    height: calc(100vh - 16px) !important;
    aspect-ratio: auto !important;
    box-shadow: none;
    border: none;
    border-radius: 0;
    /* Edge spacing comes from the @page margin (set in script.js); keep only a
       little internal padding so the grid stays wide */
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    page-break-inside: avoid;
  }

  .habit-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .habit-row {
    flex: 1;
    min-height: 0;
    page-break-inside: avoid;
  }

  .habit-input,
  .date-field input {
    border-bottom: 1px solid #1a1a1a;
  }

  .controls,
  .no-print,
  .page-header,
  .navbar,
  .footer {
    display: none !important;
  }
}
