/* ========================================
   HABIT TRACKER STYLES
======================================== */

/* ========================================
   HABIT CONTROLS
======================================== */
.habit-controls {
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.habit-btn {
  padding: 6px 14px;
  background-color: var(--light-bg-color);
  border: 1px solid var(--yellow);
  border-radius: 8px;
  font-family: 'lora', sans-serif;
  color: var(--yellow);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.habit-btn:hover {
  background-color: var(--yellow);
  color: var(--bg-color);
}

/* ========================================
   HABIT CONTAINER & CARDS
======================================== */
.habits-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.habit-card {
  background-color: var(--light-bg-color);
  border: 2px solid var(--light-bg-color);
  border-radius: 18px;
  padding: 20px;
  transition: all 0.3s ease;
}

.habit-card:hover {
  transform: translateY(-2px);
}

.habit-card.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
  z-index: 1000;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.habit-card[draggable='true'] {
  cursor: grab;
}

.habit-card[draggable='true']:active {
  cursor: grabbing;
}

/* ========================================
   HABIT HEADER & INFO
======================================== */
.habit-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.habit-info {
  flex: 1;
}

.habit-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--title-color);
  margin: 0 0 8px 0;
  font-family: 'lora', sans-serif;
}

.habit-description {
  font-size: 16px;
  color: var(--body-color);
  margin: 0;
  opacity: 0.8;
}

/* ========================================
   HABIT CHECKBOX
======================================== */
.habit-checkbox {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-color: #4a3721;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.habit-checkbox:hover {
  border: 2px solid var(--yellow);
}

.habit-checkbox input[type='checkbox'] {
  opacity: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.habit-checkbox label {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.habit-checkbox input[type='checkbox']:checked + label {
  background-color: var(--yellow);
  color: var(--bg-color);
}

/* ========================================
   HABIT GRID & DAYS
======================================== */
.habit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
  gap: 6px;
  justify-content: start;
  width: 100%;
}

.habit-day {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background-color: #4a3721;
  border: none;
  cursor: pointer;
  position: relative;
}

.habit-day:hover {
  border: 1px solid var(--yellow);
}

.habit-day.completed {
  background-color: var(--yellow);
}

.habit-day.today {
  border: 2px solid var(--yellow);
}

/* ========================================
   CUSTOM TOOLTIPS
======================================== */
.habit-day::before {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-color);
  color: var(--yellow);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: 'lora', sans-serif;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--yellow);
}

.habit-day::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  border: 5px solid transparent;
  border-top-color: var(--yellow);
  opacity: 0;
  visibility: hidden;
  z-index: 1000;
  pointer-events: none;
}

.habit-day:hover::before,
.habit-day:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-8px);
}

.habit-day:hover::after {
  transform: translateX(-50%) translateY(100%);
}

/* ========================================
   DELETE BUTTON
======================================== */
.delete-habit-btn {
  background-color: transparent;
  border: 1px solid var(--yellow);
  color: var(--yellow);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'lora', sans-serif;
  opacity: 0.4;
  margin-left: auto;
}

.delete-habit-btn:hover {
  background-color: var(--yellow);
  color: var(--bg-color);
  opacity: 1;
}

/* ========================================
   MODAL STYLES
======================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: var(--light-bg-color);
  border: 1px solid var(--yellow);
  border-radius: 18px;
  padding: 30px;
  width: 90%;
  max-width: 400px;
  animation: fade-in 0.3s ease-out;
}

.modal-content h3 {
  color: var(--title-color);
  margin: 0 0 20px 0;
  font-size: 24px;
  font-family: 'lora', sans-serif;
  font-weight: 500;
}

.habit-input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 15px;
  background-color: var(--bg-color);
  border: 1px solid var(--light-bg-color);
  border-radius: 8px;
  color: var(--body-color);
  font-size: 16px;
  font-family: 'lora', sans-serif;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

.habit-input:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 8px rgba(238, 162, 56, 0.3);
}

.habit-input::placeholder {
  color: var(--body-color);
  opacity: 0.6;
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */
@media (max-width: 810px) {
  .habit-controls {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  .habit-btn {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 8px 12px;
  }

  .habit-header {
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
  }

  .habit-card:hover {
    transform: none;
  }

  .habit-grid {
    grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
    width: 100%;
  }

  .habit-day {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 810px) {
  /* Hide tooltips on tablet and mobile */
  .habit-day::before,
  .habit-day::after {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .habit-card {
    padding: 20px;
  }

  .habit-grid {
    grid-template-columns: repeat(auto-fill, minmax(22px, 1fr));
    width: 100%;
  }

  .habit-day {
    width: 22px;
    height: 22px;
  }

  .modal-content {
    padding: 20px;
    margin: 20px;
  }

  /* Mobile touch optimizations */
  .habit-checkbox input[type='checkbox'] {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  .habit-day {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Prevent viewport jumping */
  body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
  }

  /* Remove all tap highlights globally */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Custom focus styles for better mobile experience */
  .habit-checkbox input[type='checkbox']:focus {
    outline: none;
    box-shadow: none;
  }

  .habit-checkbox input[type='checkbox']:active {
    background-color: transparent;
  }
}
