/* Modern Color Scheme */
:root {
  --primary: #5BC0EB;      /* Light blue */
  --secondary: #8EEDC7;    /* Light green */
  --accent: #34495e;       /* Dark blue */
  --background: #f9fafb;   /* Off-white */
  --text: #333333;         /* Dark gray for text */
  --white: #ffffff;        /* Pure white */
  --light-gray: #f2f2f2;   /* Light gray for alternating rows */
  --border: #e0e0e0;       /* Border color */
  --success: #66BB6A;      /* Success color */
  --warning: #FFA726;      /* Warning color */
  --error: #EF5350;        /* Error color */
  --shadow: 0 2px 10px rgba(0,0,0,0.08); /* Standard shadow */
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  line-height: 1.6;
  color: var(--text);
  background-color: var(--background);
  font-size: 18px;
}

/* Headings */
h1, h2, h3, h4 {
  color: var(--accent);
  margin-bottom: 0.8rem;
  font-weight: 500;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.75rem;
}

h4 {
  font-size: 1.5rem;
}

/* Paragraphs */
p {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

/* Header Styles */
header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--white);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 10;
}

.logo {
  height: 120px; 
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.menu-toggle {
  display: none;
  cursor: pointer;
  font-size: 1.5rem;
}

/* Layout */
.container {
  display: flex;
  min-height: calc(100vh - 72px);
  background-color: var(--background);
}

/* Sidebar Navigation */
#sidebar {
  width: 220px;
  background: var(--white);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  z-index: 5;
}

#sidebar ul {
  list-style: none;
  padding-top: 0.5rem;
}

#sidebar li {
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  margin: 0.2rem 0.5rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#sidebar li:hover {
  background: var(--light-gray);
  transform: translateX(3px);
}

#sidebar li.active {
  background: linear-gradient(to right, var(--primary), var(--secondary));
  color: var(--white);
  box-shadow: 0 2px 5px rgba(91, 192, 235, 0.3);
}

/* Main Content Area */
main {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

/* Widget Styling */
.widget {
  background: var(--white);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.widget:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.widget h2 {
  color: var(--accent);
  font-size: 1.3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Calendar Styling */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 15px;
}

.calendar div {
  padding: 12px;
  border-radius: 6px;
  min-height: 60px;
  background-color: var(--light-gray);
  font-size: 0.9rem;
}

.calendar div:nth-child(-n+7) {
  background: var(--primary);
  color: white;
  font-weight: bold;
  text-align: center;
}

/* Styles for Monthly Shifts Calendar */
.monthly-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  border: 1px solid #ccc;
  padding: 5px;
  background-color: #f9f9f9;
}

.calendar-header {
  font-weight: bold;
  text-align: center;
  padding: 5px 0;
  background-color: #eee;
  border-radius: 3px;
}

.calendar-day {
  border: 1px solid #ddd;
  min-height: 100px; /* Adjust as needed */
  padding: 5px;
  position: relative; /* For positioning add button */
  background-color: #fff;
  display: flex;
  flex-direction: column;
  font-size: 0.9em;
}

.calendar-day.empty {
  background-color: transparent;
  border: none;
}

.day-number {
  font-weight: bold;
  margin-bottom: 5px;
  align-self: flex-start;
}

.shifts-in-day {
  flex-grow: 1;
  overflow-y: auto; /* Add scroll if too many shifts */
  max-height: 70px; /* Limit height before scroll */
}

.shift-entry-monthly {
  background-color: #e0f7fa;
  border: 1px solid #b2ebf2;
  border-radius: 3px;
  padding: 2px 4px;
  margin-bottom: 3px;
  font-size: 0.8em;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shift-entry-monthly:hover {
    background-color: #b2ebf2;
}

.add-shift-day-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 18px; /* Adjust for vertical centering */
  text-align: center;
  cursor: pointer;
  opacity: 0.3; /* Initially less visible */
  transition: opacity 0.2s ease-in-out;
}

.calendar-day:hover .add-shift-day-btn {
    opacity: 1; /* Show on hover */
}

.add-shift-day-btn:hover {
  background-color: #45a049;
}

/* Styles for Weekly Schedule on Dashboard */
#weekly-schedule-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    text-align: center;
}

#weekly-schedule-calendar > div { /* Style both headers and day cells */
    border: 1px solid #eee;
    padding: 8px 4px;
    min-height: 60px; /* Ensure cells have some height */
    font-size: 0.9em;
}

#weekly-schedule-calendar > div:nth-child(-n+7) { /* Header specific styles */
    font-weight: bold;
    background-color: #f0f0f0;
}

.shift-entry { /* Style for individual shifts in weekly view */
    background-color: #f1f8e9;
    border: 1px solid #dcedc8;
    border-radius: 3px;
    padding: 2px;
    margin-top: 3px;
    font-size: 0.85em;
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Buttons */
button {
  background: linear-gradient(to right, var(--primary), var(--secondary));
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(91, 192, 235, 0.3);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(91, 192, 235, 0.4);
}

button:active {
  transform: translateY(1px);
}

#logout-button {
  background: transparent;
  border: 1px solid white;
  box-shadow: none;
}

/* Modal Styling */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  backdrop-filter: blur(3px);
}

.modal-content {
  background: white;
  margin: 5% auto;
  padding: 25px;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 5px 30px rgba(0,0,0,0.2);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close {
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
}

.close:hover {
  color: var(--error);
}

/* Form Elements */
input, select, textarea {
  display: block;
  width: 100%;
  padding: 12px;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 192, 235, 0.2);
}

label {
  font-weight: 500;
  margin: 8px 0;
  display: inline-block;
}

.error-message {
  color: var(--error);
  margin-top: 10px;
  font-size: 0.9rem;
}

/* Form Group */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.form-group input[type="text"],
.form-group input[type="email"],
#employee-modal .modal-content {
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}
.form-group input[type="tel"],
.form-group textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box; /* Include padding and border in element's total width and height */
}

.form-group textarea {
  resize: vertical; /* Allow vertical resizing */
}

.form-group select,
.form-group input[type="time"] {
  width: 100%;
  padding: 8px; /* Adjust padding to match other inputs */
  border: 1px solid var(--border); /* Use theme border color */
  border-radius: 4px; /* Match other inputs */
  box-sizing: border-box;
  font-size: 1rem; /* Match other inputs */
}

/* Space out availability options in the employee modal */
#employee-modal #availability-form {
  display: flex;
  flex-direction: column;
  gap: 18px; /* Add more vertical space between Morning, Afternoon, Evening */
  margin-bottom: 16px;
}

/* Optional: Add spacing between labels and their checkboxes */
#employee-modal #availability-form label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  margin-bottom: 0;
}

/* Page Transitions */
.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page.active {
  display: block;
}

.hidden {
  display: none !important; /* Use important if necessary to override other display rules */
}

/* Employee Cards */
.employee-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  margin-bottom: 15px;
  padding: 18px;
  background: var(--white);
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.employee-card:hover {
  transform: translateX(5px);
  border-left-color: var(--secondary);
}

.employee-card h3 {
  color: var(--accent);
  margin-bottom: 5px;
}

.employee-card p {
  color: #666;
  margin: 5px 0;
  font-size: 0.95rem;
}

.employee-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
}

.employee-actions button {
  width: auto;
  margin-left: 10px;
}

.edit-btn {
  background: var(--secondary);
}

.delete-btn {
  background: var(--error) !important; /* Use !important if needed */
  color: white !important;
  border: none !important;
}

.delete-btn:hover {
  background: #d32f2f !important; /* Darker error color on hover */
}

/* Availability Grid */
.availability-row {
  display: flex;
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
}

.availability-row:nth-child(even) {
  background-color: var(--light-gray);
}

.availability-row:first-child {
  background-color: var(--primary);
  color: white;
  font-weight: bold;
}

.availability-cell {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.availability-cell:last-child {
  border-right: none;
}

/* Shifts Calendar */
#shifts-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.calendar-header {
  background: var(--primary);
  color: white;
  font-weight: 500;
  text-align: center;
  padding: 12px;
  border-radius: 6px 6px 0 0;
}

.calendar-day {
  border: 1px solid var(--border);
  min-height: 120px;
  padding: 10px;
  background: var(--white);
  border-radius: 0 0 6px 6px;
}

.date-header {
  font-weight: 500;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.shift-item {
  background: linear-gradient(to right, var(--primary), var(--secondary));
  color: white;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: all 0.2s;
}

.shift-item:hover {
  transform: scale(1.02);
}

.add-shift-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  float: right;
  padding: 0;
  font-size: 1.2rem;
  opacity: 0.7;
}

.add-shift-btn:hover {
  opacity: 1;
}

/* Settings Page */
.setting-item {
  background-color: var(--white);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.setting-item label {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.setting-item input[type="checkbox"] {
  width: auto;
  margin-right: 10px;
}

/* Login Modal */
#login-modal .modal-content {
  max-width: 400px;
  text-align: center;
  padding: 30px;
  background: linear-gradient(to bottom right, var(--white), var(--light-gray));
}

#login-modal h2 {
  margin-bottom: 20px;
  color: var(--accent);
  text-align: center;
}

#login-modal input {
  background-color: var(--white);
}

#login-modal button {
  margin-top: 10px;
  width: 100%;
  padding: 12px;
}

.login-logo {
  height: 190px;
  margin: 0 auto 25px auto;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
}

.login-hint {
  color: #888;
  font-size: 0.95em;
  margin-top: 8px;
  text-align: center;
}

/* Form Buttons */
.form-buttons {
  display: flex; /* Arrange buttons side-by-side */
  justify-content: space-between; /* Space out Save and Delete */
  gap: 10px; /* Add space between buttons */
  margin-top: 20px; /* Add space above buttons */
}

.form-buttons button {
  flex-grow: 1; /* Make buttons share space */
}

#shift-id {
  display: none;
}

/* Availability Table Styles */
.table-container {
  overflow-x: auto; /* Add horizontal scroll if table is too wide */
  margin-top: 20px;
}

#availability-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* Helps keep columns consistent */
}

#availability-table th,
#availability-table td {
  border: 1px solid var(--border);
  padding: 10px 8px;
  text-align: center;
  font-size: 0.9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#availability-table thead th {
  background-color: var(--light-gray);
  font-weight: bold;
  position: sticky; /* Keep header visible on scroll */
  top: 0;
  z-index: 1;
}

#availability-table tbody th { /* Employee name column */
  text-align: left;
  font-weight: bold;
  background-color: var(--light-gray);
  position: sticky; /* Keep employee name visible on scroll */
  left: 0;
  z-index: 1;
}

#availability-table tbody td {
  background-color: #fbe9e7; /* Default: Unavailable (example) */
  font-size: 0.8em; /* Smaller font for detailed view */
  padding: 4px; /* Adjust padding */
  line-height: 1.2; /* Adjust line height */
  vertical-align: top; /* Align content to top */
}

#availability-table tbody td.available {
  background-color: #e8f5e9; /* Available (example) */
}

/* Style for the time slots within a cell */
.availability-slot {
  display: block; /* Each slot on a new line */
  margin-bottom: 2px;
}
.availability-slot.unavailable {
  color: #aaa; /* Dim unavailable slots */
}

/* Style for the Edit button in the availability table */
.edit-availability-btn {
  padding: 3px 6px;
  font-size: 0.8em;
  cursor: pointer;
  background-color: var(--secondary);
  color: white;
  border: none;
  border-radius: 3px;
}
.edit-availability-btn:hover {
  background-color: var(--secondary-dark);
}

/* Responsive Styles */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }
  
  #sidebar {
    width: 100%;
    display: none;
  }
  
  #sidebar.active {
    display: block;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .modal-content {
    width: 95%;
    margin: 10% auto;
  }
  
  .calendar, #shifts-calendar {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .calendar div:nth-child(n+4) {
    display: none;
  }
}

/* --- Dark Mode Styles --- */
body.dark-mode {
  --background: #121212; /* Dark background */
  --text: #e0e0e0;       /* Light text */
  --primary: #bb86fc;    /* Purple accent */
  --secondary: #03dac6;  /* Teal accent */
  --secondary-dark: #018786;
  --border: #333333;     /* Darker border */
  --light-gray: #2c2c2c; /* Darker light gray */
  --error: #cf6679;      /* Dark mode error color */
  --white: #1e1e1e;      /* Darker 'white' background for cards/modals */
  --modal-bg: rgba(255, 255, 255, 0.1); /* Dim overlay */
}

/* Adjust specific elements for dark mode */
body.dark-mode #sidebar {
  background-color: #1e1e1e; /* Slightly lighter dark for sidebar */
  border-right: 1px solid var(--border);
}

body.dark-mode #sidebar li {
  color: var(--text);
}

body.dark-mode #sidebar li:hover {
  background-color: #333333;
}

body.dark-mode #sidebar li.active {
  background-color: var(--primary);
  color: #121212; /* Dark text on primary background */
}

body.dark-mode main {
  background-color: var(--background);
}

body.dark-mode .widget {
  background-color: var(--white);
  border: 1px solid var(--border);
  box-shadow: 0 2px 5px rgba(255, 255, 255, 0.05); /* Lighter shadow */
}

body.dark-mode .widget h2 {
  color: var(--primary);
}

body.dark-mode .modal-content {
  background-color: var(--white);
  border: 1px solid var(--border);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode button {
  background-color: #2c2c2c;
  color: var(--text);
  border: 1px solid var(--border);
}
body.dark-mode input::placeholder {
    color: #888;
}

body.dark-mode button {
    background-color: var(--primary);
    color: #121212;
}
body.dark-mode button:hover {
    background-color: #a050e0; /* Darker primary */
}
body.dark-mode button.delete-btn,
body.dark-mode button#delete-shift-btn {
    background-color: var(--error) !important;
    color: #121212 !important;
}
body.dark-mode button.delete-btn:hover,
body.dark-mode button#delete-shift-btn:hover {
    background-color: #b04050 !important; /* Darker error */
}

body.dark-mode .employee-card {
    background-color: var(--white);
    border: 1px solid var(--border);
}

body.dark-mode .calendar div,
body.dark-mode .monthly-calendar div {
    border-color: var(--border);
}

body.dark-mode .calendar div:nth-child(-n+7), /* Weekly header */
body.dark-mode .calendar-header, /* Monthly header */
body.dark-mode #availability-table thead th, /* Availability header */
body.dark-mode #availability-table tbody th /* Availability name column */
{
  background-color: #333333; /* Darker header background */
  color: var(--primary);
}

body.dark-mode .calendar-day {
    background-color: var(--white);
}
body.dark-mode .calendar-day.empty {
    background-color: transparent;
}

body.dark-mode .shift-entry,
body.dark-mode .shift-entry-monthly {
    background-color: #3e275a; /* Darker shift entry */
    border-color: var(--primary);
    color: var(--text);
}

body.dark-mode #availability-table tbody td {
    background-color: #424242; /* Dark unavailable */
}
body.dark-mode #availability-table tbody td.available {
    background-color: #1b5e20; /* Dark available */
}
body.dark-mode .availability-slot.unavailable {
    color: #757575; /* Dimmer unavailable text */
}
body.dark-mode .availability-slot.available {
    color: #c8e6c9; /* Lighter available text */
}

/* Add more specific overrides as needed */

/* --- Star Rating Review Section Styles --- */
.star-rating {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  font-size: 2rem;
  margin: 10px 0;
}

.star {
  color: #ccc;
  cursor: pointer;
  transition: color 0.2s;
}

.star:hover,
.star:hover ~ .star,
.star.selected,
.star.selected ~ .star {
  color: gold;
}

#review-text {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 100px;
}

#submit-review {
  margin-top: 10px;
}

/* Review Page Styles */
#review-page .star {
  font-size: 2rem;
  color: #ccc;
  cursor: pointer;
  transition: color 0.2s;
}
#review-page .star.selected {
  color: gold;
}