/* General body styling */
body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

/* Header styling for both dashboards */
header {
  background: #2d3436;
  color: white;
  padding: 1rem;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #aed6f1; /* Light blue for apartment number */
}

/* Apartment grid layout for landlord dashboard */
.apartment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Responsive grid */
  gap: 1rem;
  padding: 2rem;
}

/* Individual apartment card styling */
.apartment {
  background: white;
  border: 1px solid #ccc;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
  border-radius: 5px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.apartment:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Modal general styling */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
  z-index: 1000; /* Ensure modal is on top */
}

.modal-content {
  background: white;
  padding: 2rem;
  width: 850px; /* Fixed width for larger screens */
  max-width: 90vw; /* Max width for responsiveness */
  border-radius: 8px;
  max-height: 90vh; /* Max height to allow scrolling */
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Grid layout within modal for tenant details */
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Two columns */
  gap: 2rem;
}

.modal-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Responsive adjustments for modal on smaller screens */
@media (max-width: 900px) {
  .modal-content {
    width: 90vw;
    padding: 1.5rem;
  }
  .modal-grid {
    grid-template-columns: 1fr; /* Single column on small screens */
  }
}

/* Close button for modals */
.close-modal {
  position: absolute;
  top: 15px;
  right: 20px; /* Adjusted to the right */
  font-size: 28px;
  cursor: pointer;
  color: #333;
  z-index: 10;
  transition: color 0.2s;
}

.close-modal:hover {
  color: #000;
}

/* Preview modal for images/PDFs */
.preview-modal-content {
  background: white;
  padding: 1rem;
  max-width: 90%;
  max-height: 90%;
  position: relative;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.close-preview {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
  color: #333;
  transition: color 0.2s;
}

.close-preview:hover {
  color: #000;
}

#previewImage {
  max-width: 100%;
  max-height: 80vh; /* Limit image height within preview */
  display: block; /* Remove extra space below image */
  margin: auto; /* Center image */
}

/* Form element styling within modals */
.modal-content form label {
  display: block;
  margin-bottom: 0.8rem;
  font-weight: bold;
}

.modal-content input[type="text"],
.modal-content input[type="email"],
.modal-content input[type="tel"],
.modal-content input[type="date"],
.modal-content textarea {
  width: calc(100% - 16px); /* Adjust for padding */
  padding: 8px;
  margin-top: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box; /* Include padding in width */
}

/* Button general styling */
button {
  margin: 0.4rem 0; /* Adjusted margin for better spacing */
  padding: 0.6rem 1.2rem;
  background: #2d3436;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s, transform 0.1s;
}

button:hover {
  background: #3b4a4e;
  transform: translateY(-2px);
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* Specific button styles */
#notifyTenantButton {
  background: #007bff; /* Blue for notification */
  margin-right: 1rem;
}

#notifyTenantButton:hover {
  background: #0056b3;
}

.clear-apartment-button {
  background: #dc3545; /* Red for destructive action */
}

.clear-apartment-button:hover {
  background: #c82333;
}

/* Apartment card (unused for landlord, but kept for reference if needed elsewhere) */
.apartment-card {
  background: white;
  padding: 1rem;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: background 0.3s;
}

.apartment-card:hover {
  background: #f1f1f1;
}

/* Lease agreement preview image within lists */
.lease-preview {
  max-width: 80px;
  max-height: 80px;
  margin-right: 0.8rem;
  vertical-align: middle;
  cursor: pointer;
  border: 1px solid #eee;
  border-radius: 3px;
}

.active-agreement {
  color: gold;
  font-size: 1.2rem;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* Login page container */
.login-container {
  max-width: 400px;
  margin: 2rem auto;
  padding: 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0,0,0,0.1);
  text-align: center;
}

.login-container h1 {
  font-size: 1.8rem;
  color: #2d3436;
  margin-bottom: 1rem;
}

.login-container h2 {
  font-size: 1.4rem;
  color: #333;
  margin-bottom: 1.5rem;
}

.login-container form label {
  display: block;
  margin-bottom: 1rem;
  text-align: left;
  font-weight: bold;
}

.login-container input,
.login-container select {
  width: 100%;
  padding: 10px;
  margin-top: 5px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 14px;
  box-sizing: border-box;
}

.login-container button {
  width: 100%;
  margin-top: 1.5rem;
  padding: 12px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
}

.login-container button:hover {
  background-color: #0056b3;
}

/* Status indicators */
.status-accepted {
  color: green;
  font-weight: bold;
}

.status-rejected {
  color: red;
  font-weight: bold;
}

.status-pending {
  color: orange;
  font-weight: bold;
}

/* Small text for timestamps, etc. */
small {
  font-size: 0.75rem; /* 12px default */
  color: #666;
}

/* Scrollable sections */
.scrollable-section {
  max-height: 250px; /* Reduced height for better modal fit */
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 0.5rem;
}

/* Custom scrollbar styling (Webkit) */
.scrollable-section::-webkit-scrollbar {
  width: 8px;
}

.scrollable-section::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.scrollable-section::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.scrollable-section::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Section styling for application and archive */
.application-section, .archive-section, .profile-section, .history-section, .upload-section {
  padding: 2rem;
  background: white;
  margin: 2rem;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

.application-section h2, .archive-section h2, .profile-section h2, .history-section h2, .upload-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: #333;
}

.application-section ul, .history-section ul, .upload-section ul {
  list-style: none;
  padding: 0;
}

.application-section li, .history-section li, .upload-section li {
  padding: 0.8rem 0;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.application-section li:last-child, .history-section li:last-child, .upload-section li:last-child {
  border-bottom: none;
}

.application-section button {
  margin-left: 0.5rem;
  padding: 0.4rem 0.8rem;
  font-size: 12px;
}

/* Message for no available apartments */
#noApartmentsMessage {
  color: #dc3545;
  font-weight: bold;
  margin-top: 0.5rem;
}

/* Payment status specific colors */
.payment-status-pending { color: #f39c12; font-weight: bold; } /* Orange */
.payment-status-approved { color: #28a745; font-weight: bold; } /* Green */
.payment-status-rejected { color: #dc3545; font-weight: bold; } /* Red */

/* Payment action buttons (approve/reject) */
.payment-action-button {
  margin-left: 0.5rem;
  padding: 0.4rem 0.8rem;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}
.payment-action-button.approve { background: #28a745; color: white; }
.payment-action-button.reject { background: #dc3545; color: white; }
.payment-action-button:hover:not(:disabled) { opacity: 0.8; } /* Hover effect only if not disabled */

/* Payment summary fixed section */
.payment-summary {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  padding: 1.2rem;
  border: 1px solid #ccc;
  box-shadow: 0 0 15px rgba(0,0,0,0.15);
  max-width: 280px; /* Adjusted width */
  max-height: 350px; /* Adjusted height */
  overflow-y: auto;
  z-index: 1000;
  border-radius: 8px;
}
.payment-summary h2 {
  font-size: 1.3rem;
  margin-top: 0;
  margin-bottom: 1rem;
  color: #333;
}
.payment-summary h3 {
  font-size: 1.1rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}
.payment-summary p {
  font-size: 0.95rem;
  margin: 0.3rem 0;
}
.payment-summary .paid {
  color: green;
  font-weight: bold;
}
.payment-summary .outstanding {
  color: red;
  font-weight: bold;
}
.payment-summary .vacant {
  color: gray;
  font-weight: bold;
}

/* Pre-formatted text for email body in history */
pre {
  white-space: pre-wrap; /* Wrap long lines */
  word-break: break-all; /* Break words to prevent overflow */
  font-family: Arial, sans-serif; /* Match body font */
  font-size: 0.9rem;
  background-color: #f8f8f8;
  border: 1px solid #eee;
  padding: 0.5rem;
  border-radius: 4px;
  margin-top: 0.5rem;
}