/* public/css/styles.css */
:root {
    --primary-color: #4caf50;
    --secondary-color: #388e3c;
    --light-green: #c8e6c9;
    --medium-green: #a5d6a7;
    --dark-text: #212121;
    --light-text: #757575;
    --border-color: #e0e0e0;
    --background-light: #f9f9f9;
  }
  
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
  }
  
  header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
  }
  
  header h1 {
    margin-bottom: 1rem;
  }
  
  nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    overflow-x: auto;
    max-width: 100%;
  }
  
  nav button {
    background-color: transparent;
    border: 2px solid white;
    color: white;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
  }
  
  nav button.active {
    background-color: white;
    color: var(--primary-color);
  }
  
  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
  }
  
  section {
    display: none;
  }
  
  section.active-view {
    display: block;
  }
  
  /* Calendar Styles */
  .month-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
  }
  
  .month-selector button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
  }
  
  .calendar-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
  }
  
  .calendar-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;  
    background-color: var(--primary-color);
    color: white;
  }
  
  .calendar-cell {
    padding: 0.75rem;
    text-align: center;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
  }
  
  .calendar-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;  
    border-bottom: 1px solid var(--border-color);
  }
  
  .calendar-row:nth-child(even) {
    background-color: var(--background-light);
  }
  
  .plant-name {
    padding: 0.75rem;
    border-right: 1px solid var(--border-color);
    cursor: pointer;
  }
  
  .plant-name:hover {
    text-decoration: underline;
    color: var(--secondary-color);
  }
  
  .month-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 1px solid var(--border-color);
  }
  
  .indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin: 0 2px;
  }
  
  .indicator.planting {
    background-color: var(--light-green);
  }
  
  .indicator.transplanting {
    background-color: var(--medium-green);
  }
  
  .indicator.harvesting {
    background-color: var(--secondary-color);
  }
  
  /* List Styles */
  .filter-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
  }
  
  .filter-controls input,
  .filter-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
  }
  
  .filter-controls input {
    flex: 1;
  }
  
  #plants-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
  }
  
  .plant-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
  }
  
  .plant-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  }
  
  .plant-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
  }
  
  .plant-card p {
    color: var(--light-text);
    font-size: 0.9rem;
  }
  
  /* Search Styles */
  .search-container {
    display: flex;
    margin-bottom: 1rem;
  }
  
  .search-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
  }
  
  .search-container button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
  }
  
  /* Modal Styles */
 
  
  .modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 2rem;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
  }
  
  .close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
  }
  
  #plant-details {
    margin-top: 1rem;
    overflow-y: auto;
  }
  
  #plant-details h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
  }
  
  #plant-details .scientific-name {
    font-style: italic;
    color: var(--light-text);
    margin-bottom: 1rem;
  }
  
  #plant-details .planting-info,
  #plant-details .description {
    margin-bottom: 1rem;
  }
  
  #plant-details .source {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--light-text);
  }
  
  /* Footer Styles */
  footer {
    background-color: var(--background-light);
    padding: 1rem;
    text-align: center;
    margin-top: 2rem;
    color: var(--light-text);
  }
  
  /* Responsive Design */
  @media (max-width: 768px) {
    .calendar-header,
    .calendar-row {
      grid-template-columns: 1fr;
    }
    
    .calendar-cell,
    .plant-name,
    .month-indicator {
      border-right: none;
      border-bottom: 1px solid var(--border-color);
    }
    
    #plants-list {
      grid-template-columns: 1fr;
    }
    
    .filter-controls {
      flex-direction: column;
    }
    
    .modal-content {
      width: 95%;
      margin: 5% auto;
    }
  }


  /* Add these styles to your styles.css file */

.source-warning {
    color: #e67e22;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 0.5rem;
  }
  
  .source-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    transition: background-color 0.2s;
  }
  
  .source-button:hover {
    background-color: var(--secondary-color);
    text-decoration: none;
    color: white;
  }
  
  .source-button i {
    margin-right: 0.5rem;
  }


  /* Update these modal styles in your styles.css file */

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto; /* Enable vertical scrolling for the modal background */
  }
  
  .modal-content {
    background-color: white;
    margin: 5% auto; /* Reduced from 10% to 5% to show more content */
    padding: 2rem;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    position: relative;
    max-height: 90vh; /* Maximum height of 90% of viewport height */
    overflow-y: auto; /* Enable scrolling for content that exceeds max-height */
  }
  
  /* Ensure fixed positioning of close button even when scrolling */
  .close-modal {
    position: sticky;
    top: 0;
    right: 1.5rem;
    float: right;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
    margin-top: -1rem;
    margin-right: -1rem;
    background-color: white;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }
  
  .close-modal:hover {
    background-color: #f5f5f5;
  }
  
  /* Make sure all content in the modal has proper spacing */
  #plant-details {
    margin-top: 1rem;
    padding-bottom: 1rem; /* Add padding at the bottom for better spacing */
  }
  
  /* Prevent body scrolling when modal is open */
  body.modal-open {
    overflow: hidden;
    /* display: block; */
  }




  
  /* Responsive adjustments */
  @media (max-width: 768px) {
    .modal-content {
      width: 95%;
      margin: 3% auto;
      padding: 1.5rem;
      max-height: 94vh; /* Slightly larger on mobile */
    }
  }



  /* Add to public/css/styles.css */

/* Plant card image styles */
.plant-card {
  display: flex;
  flex-direction: column;
}

.plant-card-header {
  display: flex;
  margin-bottom: 1rem;
  justify-content: center;
}

.plant-image-container {
  width: 80px;
  height: 80px;
  overflow: hidden;
  border-radius: 50%;
  background-color: var(--background-light);
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--light-green);
}

.plant-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: none;
}

.plant-image-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--light-green);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  color: var(--primary-color);
}

.plant-card-content {
  text-align: center;
}

/* Modal image styles */
.modal-header-container {
  display: flex;
  margin-bottom: 1.5rem;
  gap: 1.5rem;
  align-items: center;
}

.plant-info-section {
  flex: 1;
}

.plant-image-section {
  width: 200px;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--background-light);
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--light-green);
}

.plant-detail-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: none;
}

.placeholder-container {
  background-color: var(--light-green);
  opacity: 0.8;
}

.large-placeholder {
  font-size: 4rem;
  color: var(--primary-color);
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

/* Responsive design for images */
@media (max-width: 768px) {
  .modal-header-container {
    flex-direction: column-reverse;
  }
  
  .plant-image-section {
    width: 100%;
    height: 180px;
    margin-bottom: 1rem;
  }
  
  .plant-info-section {
    text-align: center;
  }
}

/* Lazy loading image styles */
img.lazy {
    opacity: 0;
    transition: opacity 0.3s ease-in;
    position: relative;
    z-index: 2; /* Make sure image is above the spinner */
  }
  
  img.lazy.loaded {
    opacity: 1;
  }
  
  .plant-image-container, .plant-image-section {
    position: relative;
    background-color: var(--background-light);
  }
  
  .plant-image-container::before, .plant-image-section::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid var(--light-green);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spinner 0.8s linear infinite;
    z-index: 1;
    transform: translate(-50%, -50%);
  }
  
  /* This is the fix - hide the spinner when image is loaded */
  .plant-image-container:has(img.loaded)::before,
  .plant-image-section:has(img.loaded)::before {
    display: none;
  }
  
  /* Fallback for browsers that don't support :has */
  img.loaded + .plant-image-container::before,
  img.loaded + .plant-image-section::before {
    display: none;
  }
  
  @keyframes spinner {
    to {
      transform: translate(-50%, -50%) rotate(360deg);
    }
  }


  /* Make calendar use the same grid layout as plants list */
#calendar-plants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
  }
  
  /* Remove old calendar table styles since we're using cards now */
  .calendar-container,
  .calendar-header,
  .calendar-row,
  .calendar-cell,
  .plant-name,
  .month-indicator,
  .indicator {
    display: none;
  }
  
  /* Highlight the current month in the month selector */
  .month-selector h2 {
    color: var(--primary-color);
    margin: 0;
    padding: 0 1rem;
    min-width: 140px;
    text-align: center;
  }
  
  /* Adjust spacing for the calendar view */
  #calendar-view .filter-controls {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }


  /* Add these to the end of your styles.css file */

/* Favorite star styles */
.favorite-button {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
  padding: 0.3rem;
  line-height: 1;
}

.favorite-button:hover {
  transform: scale(1.2);
  color: #ffdb58;
}

.favorite-button.active {
  color: #ffc107;
}

/* Plant card header with favorite button */
.plant-card-header {
  display: flex;
  margin-bottom: 1rem;
  justify-content: center;
  position: relative;
  width: 100%;
}

.plant-card .favorite-button {
  position: absolute;
  top: -5px;
  right: -5px;
  z-index: 10;
  font-size: 1.2rem;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal favorite button */
.modal-header-container {
  position: relative;
}

.modal-favorite-button {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 1.5rem;
  z-index: 10;
}

/* Favorites filter container */
.favorites-filter-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  background-color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.favorites-filter-container label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.favorites-filter-container i {
  color: #ffc107;
}

#favorites-filter {
  cursor: pointer;
}