:root {
  --accent: #e53935;
  --bg: #fff4f2;
  --text: #333;
  --line: #e53935;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 30px;
  background: #eee;
  font-family: 'Montserrat', sans-serif;
  overflow-x: hidden;
}

/* AUTH STYLES */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-box {
  background: var(--bg);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  width: 100%;
}

.auth-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 30px;
}

.auth-logo-image {
  max-width: 180px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.auth-box h3 {
  color: var(--accent);
  margin-bottom: 20px;
  font-size: 24px;
}

.auth-form input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Montserrat', sans-serif;
  box-sizing: border-box;
}

.auth-form input:focus {
  outline: none;
  border-color: #c62828;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Montserrat', sans-serif;
}

.auth-btn:hover {
  background: #c62828;
  transform: translateY(-2px);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-error {
  background: #ffebee;
  color: #c62828;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px;
  background: rgba(229, 57, 53, 0.1);
  border-radius: 8px;
}

.user-info span {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.sign-out-btn {
  padding: 6px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Montserrat', sans-serif;
}

.sign-out-btn:hover {
  background: #c62828;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(229, 57, 53, 0.1);
}

.sync-icon {
  display: inline-block;
  animation: spin 1s linear infinite;
  font-size: 14px;
}

.sync-status.synced .sync-icon {
  animation: none;
  color: #2e7d32;
}

.sync-status.synced {
  color: #2e7d32;
  background: rgba(46, 125, 50, 0.1);
}

.sync-status.error {
  color: #c62828;
  background: rgba(198, 40, 40, 0.1);
}

.sync-status.error .sync-icon {
  animation: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.planner {
  max-width: 900px;
  margin: auto;
  background: var(--bg);
  padding: 30px 40px;
  border-radius: 8px;
}

/* HEADER */
.header {
  margin-bottom: 20px;
}

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

.app-logo {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.logo-image {
  max-width: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header .small {
  font-style: italic;
  color: var(--accent);
  font-size: 18px;
}

.header h1 {
  margin: 5px 0 15px;
  color: var(--accent);
  font-size: 42px;
  letter-spacing: 1px;
}

.meta {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.meta span {
  border: 2px solid var(--accent);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
}

.view-selector {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.view-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px 12px;
  border: 2px solid var(--accent);
  border-radius: 20px;
  font-size: 13px;
  transition: all 0.3s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 36px; /* Touch-friendly size */
}

.view-option:hover {
  background: rgba(229, 57, 53, 0.1);
}

.view-option:active {
  transform: scale(0.98);
}

.view-option input[type="radio"] {
  margin-right: 8px;
  cursor: pointer;
}

.view-option input[type="radio"]:checked + span {
  font-weight: 600;
}

.view-option input[type="radio"]:checked ~ span,
.view-option:has(input[type="radio"]:checked) {
  background: var(--accent);
  color: white;
}

.view-option:has(input[type="radio"]:checked) span {
  color: white;
}

/* GRID */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 2px solid var(--line);
  border-left: 2px solid var(--line);
  width: 100%;
  overflow-x: hidden;
}

.grid.view-daily {
  grid-template-columns: 1fr;
  border-left: 0;
  border-top: 0;
}

.grid.view-daily .workout-timer-container {
  grid-column: 1;
}

.grid.view-daily .day {
  border: 2px solid var(--line);
}

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

.grid.view-monthly {
  grid-template-columns: repeat(6, 1fr);
}

.grid.view-monthly .day {
  min-height: 180px;
  font-size: 11px;
  padding: 12px;
}

.grid.view-monthly .day h3 {
  font-size: 13px;
  margin-bottom: 5px;
}

.grid.view-monthly .day .sub {
  font-size: 10px;
  margin-bottom: 8px;
}

.grid.view-monthly .day ul {
  font-size: 10px;
}

.grid.view-monthly .day li {
  font-size: 10px;
  margin-bottom: 5px;
}

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

.grid.view-weekly .day {
  min-height: 200px;
  font-size: 12px;
}

.day-navigation {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 15px 0;
}

.day-navigation.active {
  display: flex;
}

.day-navigation-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.day-nav-btn {
  padding: 8px 16px;
  border: 2px solid var(--accent);
  border-radius: 20px;
  background: white;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 40px; /* Touch-friendly size */
  touch-action: manipulation;
  flex: 1;
  max-width: 150px;
}

.day-nav-btn:hover {
  background: var(--accent);
  color: white;
}

.day-nav-btn:active {
  transform: scale(0.98);
  background: var(--accent);
  color: white;
}

.current-day-label {
  font-weight: 600;
  color: var(--accent);
  font-size: 15px;
  margin-bottom: 4px;
  text-align: center;
}

/* Workout Timer Styles */
.workout-timer-container {
  width: 100%;
  margin: 25px 0 0 0;
  padding: 25px 20px;
  background: white;
  border-top: 3px solid var(--accent);
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(229, 57, 53, 0.2);
  text-align: center;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.workout-timer-container .timer-btn {
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

.timer-display {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 20px;
  font-family: 'Montserrat', monospace;
  letter-spacing: 2px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.timer-controls {
  margin-bottom: 20px;
}

.timer-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Montserrat', sans-serif;
}

.start-btn {
  background: var(--accent);
  color: white;
}

.start-btn:hover {
  background: #c62828;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.stop-btn {
  background: #ff6b6b;
  color: white;
}

.stop-btn:hover {
  background: #ff5252;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.save-btn {
  background: var(--accent);
  color: white;
  margin-top: 15px;
}

.save-btn:hover {
  background: #c62828;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.rating-section {
  margin-top: 25px;
  padding-top: 25px;
  border-top: 2px solid #eee;
}

.rating-item {
  margin-bottom: 20px;
}

.rating-item label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 32px;
  cursor: pointer;
  flex-wrap: wrap;
  max-width: 100%;
}

.star-rating .star {
  color: #ddd;
  transition: all 0.2s;
  user-select: none;
}

.star-rating .star:hover,
.star-rating .star.hover {
  color: #ffd700;
  transform: scale(1.2);
}

.star-rating .star.active {
  color: #ffd700;
}

.star-rating .star.active:hover {
  color: #ffed4e;
}

.saved-workout-info {
  margin-top: 25px;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 8px;
  border: 2px solid var(--accent);
}

.saved-duration {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 15px;
  text-align: center;
}

.saved-duration strong {
  color: var(--accent);
}

.saved-ratings {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
  gap: 20px;
  flex-wrap: wrap;
  max-width: 100%;
}

.saved-rating-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.saved-rating-item span:first-child {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.saved-stars {
  font-size: 24px;
  color: #ffd700;
}

.redo-btn {
  background: var(--accent);
  color: white;
  width: 100%;
}

.redo-btn:hover {
  background: #c62828;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.day {
  display: block;
}

.day.hidden,
.workout-timer-container.hidden {
  display: none;
}

.day {
  padding: 18px;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  box-sizing: border-box;
}

.day h3 {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.sub {
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--accent);
}

/* CHECKLIST */
ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.exercise-text {
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

.info-icon {
  width: 18px;
  height: 18px;
  margin-left: 8px;
  cursor: pointer;
  color: var(--accent);
  opacity: 0.7;
  transition: all 0.2s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(229, 57, 53, 0.1);
  font-size: 12px;
  font-weight: bold;
}

.info-icon:hover {
  opacity: 1;
  background: rgba(229, 57, 53, 0.2);
  transform: scale(1.1);
}

.info-icon:active {
  transform: scale(0.95);
}

.check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  margin-right: 10px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.check:hover {
  background: rgba(229, 57, 53, 0.1);
}

.check.checked {
  background: var(--accent);
}

.check.checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* NOTES */
.notes {
  font-size: 13px;
  color: var(--accent);
}

.notes ul {
  margin-top: 10px;
}

.notes li {
  margin-bottom: 6px;
  font-size: 12px;
}

.lines {
  margin-top: 12px;
}

.line {
  height: 1px;
  background: var(--accent);
  margin-bottom: 8px;
  opacity: 0.6;
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg);
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--accent);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s;
  z-index: 10;
}

.modal-close:hover {
  background: #c62828;
  transform: scale(1.1);
}

.modal-close:active {
  transform: scale(0.95);
}

.modal-title {
  color: var(--accent);
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  padding: 25px 25px 15px;
  border-bottom: 2px solid var(--accent);
}

.modal-body {
  padding: 25px;
  color: var(--text);
  line-height: 1.6;
}

.modal-body h3 {
  color: var(--accent);
  font-size: 18px;
  margin: 20px 0 10px;
  font-weight: 600;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body ol,
.modal-body ul {
  margin: 10px 0;
  padding-left: 25px;
}

.modal-body li {
  margin-bottom: 8px;
  font-size: 14px;
  display: list-item;
}

.modal-body p {
  margin: 10px 0;
}

/* RESPONSIVE */
@media (max-width: 1024px) and (min-width: 769px) {
  .grid.view-weekly {
    grid-template-columns: repeat(4, 1fr);
  }

  .grid.view-monthly {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 768px) {
  body {
    padding: 15px;
  }

  .auth-logo-image {
    max-width: 150px;
  }

  .planner {
    padding: 20px 15px;
    border-radius: 0;
  }

  .header h1 {
    font-size: 28px;
    margin: 5px 0 10px;
  }

  .header-top {
    flex-wrap: wrap;
    gap: 10px;
  }

  .logo-image {
    max-width: 100px;
  }

  .header-actions {
    flex-shrink: 0;
  }

  .meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  .meta span {
    font-size: 12px;
    padding: 5px 10px;
  }

  .view-selector {
    flex-direction: row;
    gap: 6px;
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .view-option {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    font-size: 12px;
    min-height: 36px;
  }

  .day-navigation {
    gap: 8px;
    margin: 12px 0;
  }

  .day-navigation-buttons {
    width: 100%;
    gap: 10px;
  }

  .day-nav-btn {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    min-height: 40px;
    max-width: none;
  }

  .current-day-label {
    font-size: 14px;
    margin-bottom: 4px;
  }

  /* Grid layouts for mobile */
  .grid.view-daily {
    grid-template-columns: 1fr;
  }

  .grid.view-weekly {
    grid-template-columns: 1fr;
  }

  .grid.view-monthly {
    grid-template-columns: 1fr;
  }

  .day {
    padding: 15px;
    font-size: 14px;
  }

  .day h3 {
    font-size: 18px;
  }

  .sub {
    font-size: 12px;
    margin-bottom: 8px;
  }

  li {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .check {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-right: 12px;
  }

  .check.checked::after {
    font-size: 14px;
  }

  .info-icon {
    width: 22px;
    height: 22px;
    font-size: 14px;
    min-width: 22px;
  }

  .notes {
    font-size: 12px;
  }

  .notes li {
    font-size: 11px;
  }

  .modal-content {
    max-width: 100%;
    margin: 10px;
    max-height: 95vh;
  }

  .modal-title {
    font-size: 22px;
    padding: 20px 20px 12px;
  }

  .modal-body {
    padding: 20px;
  }

  .modal-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
    top: 10px;
    right: 10px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .planner {
    padding: 15px 10px;
  }

  .header h1 {
    font-size: 24px;
  }

  .auth-logo-image {
    max-width: 120px;
  }

  .logo-image {
    max-width: 80px;
  }

  .sign-out-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .meta span {
    font-size: 11px;
    padding: 4px 8px;
  }

  .day {
    padding: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  .workout-timer-container {
    padding: 20px 15px;
    margin: 20px 0 0 0;
  }
  
  .timer-display {
    font-size: 36px;
  }
  
  .star-rating {
    font-size: 24px;
    gap: 6px;
  }

  .day h3 {
    font-size: 16px;
  }

  .sub {
    font-size: 11px;
  }

  li {
    font-size: 12px;
  }

  .current-day-label {
    font-size: 12px;
    line-height: 1.4;
  }
}
</style>
