/* MOVEMENTS */
:root {
  --color-primary: #88c273;
  --color-secondary: #889eaf;
  --color-tertiary: #f96666;
  --color-primary-darker: #729763;
  --color-secondary-darker: #506d84;
  --color-tertiary-darker: #dd5353;
  --color-primary-opacity: rgb(114, 151, 99, 0.4);
  --color-secondary-opacity: #ffcd0331;
  --color-tertiary-opacity: rgb(221, 83, 83, 0.4);
  --color-temporary: #ffcb03;
  --color-temporary-darker: #ffbb00;
  --gradient-primary: linear-gradient(to top left, #39b385, #9be15d);
  --gradient-secondary: linear-gradient(to top left, #ffb003, #ffcb03);
}

.movements {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-radius: 1rem;
  padding: 2rem;
  height: calc(8 * 6rem + 14rem); /* 8 rows + pagination height */
  max-width: 100%;
  box-sizing: border-box;
}

/* Mobiili-määritykset - iPhone 14 Pro Max ja muut suuret mobiilit */
@media (max-width: 480px) {
  .movements {
    padding: 1.5rem;
    height: auto;
    min-height: calc(6 * 5rem + 12rem); /* Pienemmät rivit + pagination */
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .movements__row {
    grid-template-columns: 60px 1fr auto;
    gap: 1rem;
    padding: 0.8rem;
    height: 5rem;
    min-width: 0;
    overflow: hidden;
  }

  .movements__pagination {
    padding: 1rem;
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .movements__pagination button {
    font-size: 1.4rem;
    padding: 0.6rem 1.2rem;
    min-height: 44px;
  }

  /* Movements row sisällön optimointi */
  .movements__date {
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .movements__description {
    font-size: 1.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }

  .movements__value {
    font-size: 1.3rem;
    white-space: nowrap;
    font-weight: 600;
  }
}

.movements__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.movements__row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 2rem;
  align-items: center;
  padding: 1rem 1rem;
  height: 6rem; /* Fixed height for each row */
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  border-left: 4px solid transparent;
  transition: transform 0.2s, background-color 0.2s;

  /* Grid item overflow korjaukset */
  min-width: 0;
  overflow: hidden;
}

/* Empty row styling */
.movements__row.empty {
  background-color: #f8f9fa;
  border-left: none;
}

.movements__row:hover {
  background-color: #f0f0f0;
  transform: scale(1.01);
}

.movements__row.selected {
  background-color: #e6e6e6;
  border: 2px solid #666;
}

.movements__type--deposit {
  /* background-image: linear-gradient(to top left, var(--color-primary-darker), var(--color-primary)) !important; */
  background-color: rgb(136, 194, 115, 0.8) !important;
}

.movements__type--withdrawal {
  /* background-image: linear-gradient(to top left, var(--color-tertiary-darker), var(--color-tertiary)) !important; */
  background-color: rgb(249, 102, 102, 0.8) !important;
}

.movements__description {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.7rem;
  font-weight: 500;
  padding: 0.8rem 1.2rem;
  border-radius: 0.5rem;
  color: #333;
  max-width: 20rem;
  align-self: center;

  /* Text overflow korjaukset */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0; /* Grid item korjaus */
}

.movements__date {
  font-size: 1.5rem; /* Increased font size */
  text-transform: uppercase;
  font-weight: 500;
  color: #666;
  text-align: center; /* Keskitetään päivämäärä */
  margin-bottom: 0; /* Poistetaan marginaali */
}

.movements__value {
  font-size: 1.8rem; /* Increased font size */
  color: #333;
  text-align: right; /* Lisätty oikealle tasaus */
  display: flex; /* Lisätään flex */
  align-items: center; /* Keskitetään pystysuunnassa */
  justify-content: flex-end; /* Pidetään teksti oikealla */
}

.movements__pagination {
  width: 100%;
  margin-top: auto;
  padding: 1.5rem;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: center;
  gap: 1rem;
  align-items: center;
  background-color: #fff;
  border-top: 1px solid #eee;
  border-radius: 1rem;
}

.movements__pagination button {
  font-family: inherit;
  font-size: 1.6rem;
  border: none;
  background-color: #f3f3f3;
  padding: 0.8rem 1.5rem;
  border-radius: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}

.movements__pagination button:hover:not(:disabled) {
  background-color: #e6e6e6;
}

.movements__pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.movements__pagination--current {
  font-size: 1.6rem;
  font-weight: 500;
  color: #666;
}

.recurrence-end-container {
  transition: display 0.3s ease-in-out;
  margin-top: 10px;
}

.recurrence-end-container.hidden {
  display: none;
}

/* Recurrence-kuvakkeen tyylit */
.recurrence-icon {
  font-size: 2.2rem;
  margin-left: 0.5rem;
  color: #333;
  display: inline-block;
  vertical-align: middle;
}

/* Hover-efekti */
/* .recurrence-icon:hover {
  color: #333;
  transform: scale(1.1);
  transition: all 0.2s ease;
} */

/* iOS specific fixes for movements */
@supports (-webkit-touch-callout: none) {
  .movements__row {
    /* Varmista että grid toimii iOS:ssä */
    display: grid;
    grid-template-columns: 80px 1fr auto;
    align-items: center;
    min-height: 0; /* Poista min-height konfliktit */
  }

  .movements__description {
    /* iOS text rendering korjaus */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .movements__date,
  .movements__value {
    /* iOS font rendering */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
  }

  .movements__pagination {
    /* iOS flexbox korjaus */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
  }

  .movements__pagination button {
    /* iOS button korjaus */
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    border: none;
    outline: none;
  }
}

/* Touch-friendly korjaukset mobiililaitteille */
@media (hover: none) and (pointer: coarse) {
  /* Tämä tunnistaa touch-laitteet */
  .movements__row {
    min-height: 44px; /* iOS minimum touch target */
    padding: 0.8rem 1rem;
    height: auto;
  }

  .movements__row:hover {
    /* Poista hover efektit touch-laitteilla */
    background-color: #f8f9fa;
    transform: none;
  }

  .movements__row:active {
    /* Lisää active state touch-laitteille */
    background-color: #e6e6e6;
    transform: scale(0.98);
  }

  .movements__pagination button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.8rem 1.2rem;

    /* Touch feedback */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  .movements__pagination button:active {
    background-color: #d6d6d6;
    transform: scale(0.95);
  }
}

/* Empty state for new accounts */
.movements__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 20rem;
  padding: 2rem;
  text-align: center;
  color: #6c757d;
}

.movements__empty p {
  margin: 0.5rem 0;
  font-size: 1.1rem;
}

.movements__empty p:first-child {
  font-weight: 600;
  font-size: 1.3rem;
  color: #495057;
}
