/* Base Styles */
body {
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  padding: 1rem 2rem;
  background-color: #f5f7fa;
  color: #333;
}

h1 {
  margin-bottom: 1rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 2fr));
  grid-gap: 20px;
  margin: 0 auto;
}

.widget {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  padding: 1rem;
}

.widget h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #555;
}

/* Table Container - Critical for mobile scrolling */
.widget-section {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 1rem;
  border-radius: 8px;
}

/* Table Styles */
table {
  width: 100%;
  min-width: 600px; /* Forces horizontal scroll on mobile */
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  text-align: left;
}

th {
  background: #f0f0f0;
  color: #555;
}

/* Interactive Elements */
.icon-button {
  background: none;
  border: none;
  padding: 0.3rem;
  font-size: 1.2rem;
  cursor: pointer;
  color: #444;
}

.icon-button:hover {
  color: #1f4946;
  transform: scale(1.1);
}

.common-button {
  background-color: #2d87f0;
  color: white;
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.common-button:hover {
  background-color: #1c6ed5;
}

/* Modal Styles */
#modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
}

#modal .modal-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  position: relative;
}

.day-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.day-row label {
  width: 100px;
  font-weight: 500;
}

#modal.hidden {
  display: none;
}

.modal-content label {
  display: block;
  margin: 0.75rem 0 0.3rem;
}

.modal-content input, .modal-content select {
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.modal-content .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1rem;
}

/* Header Styles */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

#openModal {
  font-size: 20px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  text-align: center;
  line-height: 36px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s;
  padding: 0;
}

#openModal:hover {
  background-color: #45a049;
}

#dashboard-actions {
  align-items: flex-end;
}

/* Dark Mode Styles */
body.dark {
  background-color: #121212;
  color: #e0e0e0;
}

body.dark .widget, 
body.dark .modal-content {
  background-color: #1e1e1e;
  border-color: #333;
}

body.dark table {
  border-color: #444;
}

body.dark input, 
body.dark select {
  background-color: #2c2c2c;
  color: #f1f1f1;
  border-color: #555;
}

body.dark table {
  background-color: #1e1e1e;
  color: #f0f0f0;
}

body.dark table th,
body.dark table td {
  border-color: #444;
}

body.dark table thead {
  background-color: #2a2a2a;
}

body.dark #modal {
  background-color: rgba(0, 0, 0, 0.8);
}

body.dark #modal .modal-content {
  background-color: #1e1e1e;
  color: #fff;
}

body.dark input,
body.dark select {
  background-color: #1e1e1e;
  color: #f0f0f0;
  border: 1px solid #555;
}

body.dark h2,
body.dark label {
  color: #ccc;
}

body.dark .modal-actions button {
  background-color: #444;
  color: #fff;
  border: none;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .widget {
    padding: 0.75rem;
  }
  
  /* Slightly reduce table cell padding on mobile */
  th, td {
    padding: 0.5rem 0.75rem;
  }
}

/* Tablet Responsiveness (768px and below) */
@media screen and (max-width: 768px) {
  body {
    padding: 1rem;
  }

  /* Header adjustments */
  .header-bar {
    flex-direction: row; /* Keep horizontal layout */
    align-items: center;
    margin-bottom: 1.25rem;
  }

  .header-bar h1 {
    font-size: 1.5rem; /* Slightly smaller than desktop */
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden;
    text-overflow: ellipsis; /* Add ... if text is too long */
    max-width: 80%; /* Leave space for buttons */
  }

  .dashboard-actions {
    gap: 0.5rem;
  }

  /* Dashboard grid */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem; /* Slightly smaller gap than desktop */
  }

  .widget {
    padding: 1rem; /* Slightly reduced padding */
  }

  /* Table adjustments */
  .widget-section {
    margin: 0 -0.5rem; /* Allow table to bleed to edges slightly */
    padding: 0 0.5rem;
  }

  table {
    min-width: 650px; /* Ensure horizontal scrolling */
  }

  th, td {
    padding: 0.6rem 0.8rem; /* Slightly reduced padding */
    font-size: 0.95rem; /* Slightly smaller font */
  }

  /* Modal adjustments */
  #modal .modal-content {
    width: 90%;
    padding: 1.5rem;
  }

  /* Form elements */
  .day-row {
    gap: 0.4rem;
  }

  .modal-content input, 
  .modal-content select {
    padding: 0.45rem;
  }

  /* Buttons */
  .icon-button {
    padding: 0.25rem;
    font-size: 1.1rem;
  }

  #openModal {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
}

/* Additional Mobile Responsiveness (480px and below) */
@media screen and (max-width: 480px) {
  .header-bar h1 {
    font-size: 1.3rem;
    max-width: 80%; /* More space for buttons on very small screens */
  }

  .dashboard-actions {
    gap: 0.4rem;
  }

  .widget {
    padding: 0.8rem;
  }

  th, td {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
  }
}