/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #2d3748;
  line-height: 1.6;
}

.container { max-width: 1600px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.header {
  background: #34495E;
  border-bottom: 2px solid #2C3E50;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
  font-size: 1.5rem;
  color: white;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #E0E6ED;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #48bb78;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}
.refresh-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}
.refresh-btn svg {
    width: 18px;
    height: 18px;
}

/* Stats Section */
.stats {
  padding: 1.5rem 0;
  border-bottom: 1px solid #e2e8f0;
  background: #f9fafb;
}

.stats .container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.stat-box {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: #2d3748;
  line-height: 1;
}

/* Calendar Controls */
.controls-wrapper {
    margin: 1.5rem 0 0 0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.filter-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    background-color: white;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-group label {
  font-size: 0.875rem;
  font-weight: 500;
}

.region-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.region-btn {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  background-color: transparent;
}

.region-btn.active { 
    border: 2px solid !important;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-box-wrapper {
    position: relative;
}
.search-box-wrapper svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: #9ca3af;
}

.search-box {
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  font-size: 0.875rem;
  min-width: 250px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #f8fafc;
    flex-wrap: wrap;
    gap: 1rem;
}

.date-navigation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.nav-arrow:hover {
    background-color: #1a2b3c;
}
.nav-arrow svg {
    width: 20px;
    height: 20px;
}

.date-display-main {
    font-weight: 600;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
    min-width: 200px;
    background: white;
    cursor: pointer;
    transition: background-color 0.2s;
}
.date-display-main:hover {
    background-color: #f8fafc;
}

.today-btn-new {
    padding: 0.5rem 1rem;
    background-color: #e2e8f0;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}
.today-btn-new:hover {
    background-color: #cbd5e0;
}

.view-switcher {
    display: flex;
    gap: 0.5rem;
    background-color: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: #4a5568;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn.active {
    background-color: #2c3e50;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Main Content */
.main { padding: 1.5rem 0 2rem 0; }

.view-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}

.calendar-wrapper { overflow-x: auto; }

.calendar-table, .hourly-table, .monthly-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

.calendar-table th, .hourly-table th, .monthly-table th {
  background: #f7fafc;
  padding: 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid #e2e8f0;
}

.calendar-table tr.main-header-row th, .hourly-table tr.main-header-row th, .monthly-table tr.main-header-row th {
    background-color: #2c3e50;
    color: white;
    border-bottom: 1px solid #4a6075;
    text-align: center;
    transition: all 0.3s ease;
}

.calendar-table tr.main-header-row th.name-col, .hourly-table tr.main-header-row th.name-col {
    background-color: #2c3e50;
    text-align: left; 
    border-right: 2px solid white;
    vertical-align: middle;
}

.calendar-table tr.sub-header-row th {
    background-color: #34495e; 
    font-weight: 500;
    color: #f0f3f5; 
    border-bottom: 2px solid #2c3e50;
    transition: all 0.3s ease;
}

.calendar-table tr.sub-header-row .period-divider {
    border-right: 1px solid #4a6075;
}

/* Column hover effects */
.calendar-table .day-column-header.hovered {
    background-color: #4a90e2 !important;
    color: #ffffff !important;
    transform: scale(1.05);
    z-index: 50;
}

.calendar-table .day-column-cell.hovered {
    background-color: rgba(74, 144, 226, 0.15) !important;
    transform: scale(1.02);
}

.hourly-table th {
  border-right: 1px solid #a0aec0;
}

.hourly-table td {
  border-right: 1px solid #a0aec0;
}

.hourly-table th:last-child,
.hourly-table td:last-child {
  border-right: none;
}

.day-divider {
    border-right: 1px solid #a0aec0;
}

.calendar-table tbody .day-divider, .hourly-table tbody .day-divider {
    border-right: 1px solid #a0aec0;
}

.calendar-table tbody .period-divider {
    border-right: 1px solid #e2e8f0;
}

.today-header-main {
    background-color: #fed68a !important;
    color: #78350f !important;
}
.today-header-sub {
    background-color: #fee3ae !important;
    color: #78350f !important;
}
.today-cell.slot.unavailable, .today-cell.slot:not(.booked):not(.available) {
    background-color: #fef2d7 !important; 
}

.today-cell.slot.booked {
    background-color: #fff5f5 !important;
}
.today-cell.slot.available {
    background-color: #f0fff4 !important;
}

.calendar-table th.name-col, .hourly-table th.name-col, .monthly-table th.name-col {
  min-width: 150px;
  max-width: 150px;
  width: 150px;
  position: sticky;
  left: 0;
  z-index: 10;
}

.calendar-table td, .hourly-table td, .monthly-table td {
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  font-size: 0.875rem;
  vertical-align: top;
  transition: all 0.2s ease;
}

.calendar-table td, .hourly-table td {
  border-top: none;
  border-left: none;
  border-bottom: 1px solid #a0aec0;
}
.hourly-table td {
  border-right: 1px solid #a0aec0;
}

.calendar-table td.name-col, .hourly-table td.name-col {
  position: sticky;
  left: 0;
  background: #e2e8f0;
  font-weight: 500;
  z-index: 11; 
  vertical-align: middle; 
  text-align: left; 
  padding-left: 1rem;
  min-width: 150px;
  max-width: 150px;
  width: 150px;
}

.calendar-table td.name-col::after, .hourly-table td.name-col::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: -1px;
  width: 3px;
  background-color: #2c3e50;
  z-index: 12;
}

/* Monthly View Styles */
.monthly-table { 
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0;
    background-color: white;
    border: none;
}
.monthly-table th { 
    border-right: 1px solid #4a6075;
}
.monthly-table tr.main-header-row th:first-child {
    border-top-left-radius: 8px;
}
.monthly-table tr.main-header-row th:last-child {
    border-top-right-radius: 8px;
    border-right: none;
}
.monthly-table td { 
    height: 120px; 
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.monthly-table td:hover {
    background-color: #f8fafc;
}
.day-number { font-weight: 600; font-size: 0.875rem; text-align: left; }
.day-stats { font-size: 0.75rem; margin-top: 0.5rem; }
.day-stats div { display: flex; align-items: center; gap: 0.3rem; }
.available-stat { color: #2f855a; }
.booked-stat { color: #c53030; }
.month-today { 
    background-color: #fef9c3;
    border: 2px solid #fde047;
}
.other-month { 
    background-color: #f7fafc; 
}
.other-month .day-number, .other-month .day-stats {
    visibility: hidden;
}

.cleaner-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.cleaner-name {
  font-weight: 600;
  color: #2d3748;
}

.cleaner-region {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  display: inline-block;
  width: fit-content;
  border: 1px solid;
}

.slot {
  min-height: 60px;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.slot:hover { opacity: 0.9; transform: scale(1.02); }

.slot.available {
  background: #f0fff4;
  border-left: 3px solid #48bb78;
  color: #2f855a;
}

.slot.booked {
  background: #fff5f5;
  border-left: 3px solid #f56565;
}

.slot.unavailable {
  background: #f7fafc;
  color: #a0aec0;
}

.job-info {
  font-size: 0.75rem;
  line-height: 1.4;
}

.job-number {
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 0.25rem;
}

.job-customer {
  color: #4a5568;
  margin-bottom: 0.25rem;
}

.job-address {
  color: #718096;
  font-size: 0.7rem;
}

.job-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: #c53030;
  margin-top: 0.25rem;
}

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e2e8f0;
  border-top-color: #4299e1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Date Picker Modal */
.datepicker-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}
.datepicker-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
.datepicker-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}
.datepicker-content {
    position: relative;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    max-width: 350px;
    width: 90%;
}
.datepicker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.datepicker-month-year {
    font-weight: 600;
}
.datepicker-year-select {
    font-weight: 600;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
}
.datepicker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}
.datepicker-day, .datepicker-weekday {
    padding: 0.5rem;
}
.datepicker-weekday {
    font-weight: 600;
    font-size: 0.75rem;
    color: #718096;
}
.datepicker-day {
    cursor: pointer;
    border-radius: 50%;
}
.datepicker-day:hover {
    background-color: #f1f5f9;
}
.datepicker-day.other-month-day {
    color: #a0aec0;
}
.datepicker-day.today {
    background-color: #fee3ae;
    color: #78350f;
    font-weight: 700;
}
.datepicker-day.selected {
    background-color: #2c3e50;
    color: white;
}

/* Other Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.modal.active { display: block; }

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
  border: none;
  background: none;
  cursor: pointer;
  color: #718096;
  line-height: 1;
}

.modal-close:hover { color: #2d3748; }

/* Cleaners List Styles */
.cleaners-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}
.cleaner-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}
.cleaner-card h3 {
    margin-bottom: 0.5rem;
}
.cleaner-card p {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: #4a5568;
}
.cleaner-card strong {
    color: #2d3748;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .calendar-table, .hourly-table {
        min-width: 800px;
    }
    
    .calendar-table th.name-col, .hourly-table th.name-col,
    .calendar-table td.name-col, .hourly-table td.name-col {
        min-width: 120px;
        max-width: 120px;
        width: 120px;
    }
}

@media (max-width: 768px) {
    .header h1 { font-size: 1.25rem; }
    .header-right { gap: 1rem; }
    
    .stats .container { 
        grid-template-columns: 1fr; 
    }
    
    .filter-controls { 
        flex-direction: column; 
        align-items: stretch; 
    }
    
    .filter-group {
        width: 100%;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .calendar-controls { 
        flex-direction: column; 
        gap: 1rem; 
    }
    
    .date-navigation { 
        width: 100%; 
        justify-content: center; 
    }
    
    .date-display-main {
        min-width: auto;
        flex: 1;
    }
    
    .view-switcher { 
        width: 100%; 
    }
    
    .view-btn { 
        flex: 1;
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .cleaner-card { 
        min-width: 250px; 
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .calendar-table th.name-col, .hourly-table th.name-col,
    .calendar-table td.name-col, .hourly-table td.name-col {
        min-width: 100px;
        max-width: 100px;
        width: 100px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1rem;
    }
    
    .status {
        font-size: 0.75rem;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .view-btn {
        font-size: 0.7rem;
        padding: 0.4rem 0.4rem;
    }
    
    .region-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }
}
