@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  html {
    font-family: 'Manrope', system-ui, sans-serif;
  }
}

body {
  background-color: #f7f8fb;
  font-family: 'Manrope', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
}

input,
button {
  margin: 0;
}

.flash-error {
  background-color: #fee2e2;
  color: #991b1b;
}

.flash-notice {
  background-color: #d8eddc;
  color: #00823e;
}

.button_to {
  margin: 0; /* Resets all margins (top, right, bottom, left) */
}

.btn {
  @apply flex items-center justify-center font-semibold text-center rounded-lg;
}

.btn-primary {
  @apply text-white bg-black border border-black border-solid btn hover:bg-primary-800;
}

.btn-secondary {
  @apply text-sm bg-white border border-solid btn border-cool-gray-200 text-cool-gray-800 hover:bg-cool-gray-50;
}

.btn-sm {
  @apply py-2.5 px-4 rounded-lg text-sm flex items-center;
}

.btn-md {
  @apply flex items-center px-4 py-3 text-sm rounded-lg;
}

.text-secondary {
  color: #626d7c;
}

.input-label {
  @apply block text-sm font-semibold text-cool-gray-700;
}

.input-label-error {
  @apply text-red-600; /* Red label text for errors */
}

.input-field {
  @apply block w-full font-medium text-cool-gray-900 rounded-md border border-gray-100 focus:outline-blue-600 px-4 py-3 mt-1.5;
}

.input-field-error {
  @apply border-red-600; /* Red border for errors */
}

.modal {
  @apply w-full lg:w-fit;
  border: none;
  margin: auto;
  box-shadow: 0px 20px 24px -4px rgba(16, 24, 40, 0.08),
    0px 8px 8px -4px rgba(16, 24, 40, 0.03);
  border-radius: 12px;
  background: white;
  padding: 24px;

  &::backdrop {
    background: rgba(52, 64, 84, 0.7);
    backdrop-filter: blur(8px);
  }
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.jounral-day-navigation-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.jounral-day-navigation-button.disabled {
  opacity: 0.5;
  pointer-events: none; /* Prevents interaction */
  cursor: not-allowed;
}

.completion-buttons {
  display: flex;
  flex-direction: row;
  gap: 6px;
}
.completion-button {
  display: flex; /* enables flexbox */
  align-items: center; /* vertically center child items */
  justify-content: center; /* horizontally center child items */
  background-color: #ebedf0;
  height: 36px;
  width: 36px;
  padding: 4px;
  border-radius: 4px;
}

.completion-button.active {
  background-color: #000000;
}

.completion-button-icon {
  height: 14px;
  width: 14px;
}

.completion-button.active .completion-button-icon path {
  stroke: white; /* Changes currentColor for SVG */
}

@media (min-width: 640px) {
  .completion-button {
    height: 24px;
    width: 24px;
  }
}

.week-cluster {
  overflow: auto hidden;
  white-space: nowrap;
  opacity: 0; /* Hide until JS runs to prevent flash of unstyled content. Without this mechanism, the full week-cluster is briefly visible on page load.*/
  display: flex;
  flex-direction: row;
  width: 100%;
  padding-top: 32px;
  position: relative; /* Ensure offsetLeft is relative to this container */
}

.week-cluster.ready {
  opacity: 1; /* Show when ready. Without this mechanism, the full week-cluster is briefly visible on page load.*/
}

@media (max-width: 640px) {
  .week-cluster {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    padding-bottom: 16px; /* Add padding to account for the scrollbar space */
    margin: 0 -18px; /* Negative margin to align with card padding */
    padding: 32px 18px 9px 18px; /* Add horizontal padding to match card */
    width: calc(
      100% + 36px
    ); /* Adjust width to account for the negative margins */
  }

  .week-cluster::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
  }
}

.week-cluster-cut {
  padding-right: 32px; /* Add horizontal padding to match card */
  width: calc(
    100% + 32px
  ); /* Adjust width to account for the negative margins */
}

.week {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.week:first-of-type {
  justify-content: flex-end;
}

.habit-block {
  position: relative;
  margin: 2px;
  background: #ebedf0;
  border: 1px solid #dfe1e4;
  border-radius: 2px;
  width: calc(100% - 4px);
  aspect-ratio: 1 / 1; /* Keep the block square by setting height equal to width */
}

.week-cluster-cut .habit-block {
  height: 16px;
  width: 16px;
}

@media (max-width: 640px) {
  .habit-block {
    height: 16px;
    width: 16px;
  }
}

.habit-block.completed {
  background-color: #00823e;
  border: none;
}

.habit-block.incompleted {
  border: 1px solid #ed9d97;
  background-color: #ffd2d0;
}

.habit-block:hover {
  display: block;
  cursor: pointer;
}

.habit-block:hover .log-tooltip {
  display: block;
}

.log-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
  margin-bottom: 3px;
  pointer-events: none;
}

.week-cluster .week:first-child .log-tooltip {
  left: 40px !important;
}

.week-cluster .week:nth-child(2) .log-tooltip {
  left: 20px !important;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px 32px;
  background: #ffffff;
  border: 1px solid #e2e5eb;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .card-sign-up {
    background: transparent;
    border: none;
    width: 100%;
  }

  .card {
    padding: 20px 18px;
  }
}

#search_results {
  position: absolute;
  z-index: 10;
  width: 100%;
  @apply mt-1;
}

#loading {
  position: absolute;
  z-index: 10;
  width: 100%;
  @apply mt-1;
}

.terms-page {
  h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 16px;
  }
  p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 16px;
  }
  a {
    text-decoration: underline;
  }
  ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-bottom: 16px;
  }
  li {
    margin-bottom: 8px;
  }
  h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #000000;
    margin-top: 32px;
    margin-bottom: 16px;
  }
}

.share-card {
  width: 66.6667%; /* Match the image width */
  background: white;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 12px;
}

.share-title {
  font-weight: 700;
  font-size: 24px;
  @apply text-xs lg:text-2xl;
}

.share-habit-block {
  position: relative;
  background: #ebedf0;
  border: 0.5px solid #dfe1e4 !important;
  border-radius: 2px;
  width: 100%;
  aspect-ratio: 1 / 1; /* Keep the block square by setting height equal to width */
}

.share-week-cluster {
  display: flex;
  flex-direction: row;
  width: 100%;
  padding-top: 24px;
  position: relative; /* Ensure offsetLeft is relative to this container */
  gap: 2px;
}

.share-habit-block.completed {
  background-color: #00823e;
  border: none;
}
.share-habit-block.incompleted {
  border: 1px solid #ed9d97 !important;
  background-color: #ffd2d0;
}
.share-habit-block.future-days {
  border: 1px solid #edeef0 !important;
  background-color: #fafafb;
}

.share-toggle-buttons {
  display: flex;
  gap: 10px;
}

.share-toggle-button {
  padding: 8px 16px;
  border: 1px solid #ccc;
  cursor: pointer;
  @apply w-full h-full text-sm font-semibold text-center text-cool-gray-800;
}

.share-toggle-button.active {
  @apply bg-cool-gray-50;
}

.share-color-tile {
  @apply w-[calc((100%-3.75rem)/6)] aspect-square border border-transparent rounded-lg cursor-pointer border-gray-200;
}

.share-color-tile.selected {
  @apply border-[2px] border-blue-500;
}

.share-week-cluster {
  @apply flex flex-row;
  padding-top: 8px;
  position: relative; /* Ensure offsetLeft is relative to this container */
}
.share-week {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 2px;
}

.fire-icon {
  color: #3259e8;
}

.share-week:first-of-type {
  justify-content: flex-end;
}

@media (min-width: 960px) {
  .share-card {
    border-radius: 24px;
    padding: 28px;
  }
  .share-habit-block {
    border-radius: 4px;
    border: 1px solid #dfe1e4 !important;
  }
  .share-week-cluster {
    gap: 5px;
    padding-top: 24px;
  }
  .share-week {
    gap: 5px;
  }
}
