:root {
  --primary: #2563eb;
  --light: #dbeafe;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --white: #fff;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 4px;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Layout */
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-100);
}
.app-container { max-width: 1200px; margin: auto; }
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem; background: var(--white); box-shadow: var(--shadow);
}
.logo { display: flex; align-items: center; gap: .5rem; color: var(--primary); }
.user-info { display: flex; align-items: center; gap: 1rem; }
.avatar {
  width: 2.5rem; height: 2.5rem; background: var(--primary);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: var(--white); font-weight: bold;
}

.main-content {
  background: var(--white); margin: 1rem; padding: 2rem; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.page-header h2 { margin-bottom: .25rem; }
.page-header p { color: var(--gray-600); }

/* Week Navigation */
.week-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.week-nav-btn {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.week-nav-btn:hover {
  background: var(--gray-100);
}

.week-info-container {
  text-align: center;
}

.week-info {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.week-dates {
  color: var(--gray-600);
  font-size: 0.9rem;
}

/* Controls */
.controls {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;
  flex-wrap: wrap;
}
.day-selector {
  display: flex; gap: .5rem; flex-wrap: wrap;
}
.day-btn {
  padding: .5rem 1rem; border: 1px solid var(--gray-300);
  background: var(--white); border-radius: var(--radius);
  cursor: pointer; transition: .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.day-btn.active { 
  background: var(--primary); 
  color: var(--white); 
}
.day-btn.today {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--light);
}
.date-label {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  opacity: 0.8;
}

/* Copy/Paste */
#copy-day, .paste-select, .action-btn {
  padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid var(--gray-300);
  background: var(--white); cursor: pointer; transition: .2s;
}
.paste-select { background: var(--white); }
.action-btn:hover { background: var(--gray-100); }

/* AI Button */
.ai-btn {
  background-color: #f0f9ff;
  border-color: #38bdf8;
  color: #0284c7;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ai-btn:hover {
  background-color: #e0f2fe;
}

/* Time Grid (24h x 4) */
.time-grid-container { overflow-x: auto; margin-bottom: 1rem; }
.time-grid {
  display: grid; grid-template-columns: repeat(24, minmax(60px,1fr));
  gap: .25rem;
}
.slot {
  position: relative; padding: .5rem; background: var(--gray-100);
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  text-align: center; cursor: pointer; transition: .2s;
}
.slot.selected { background: var(--light); border-color: var(--primary); }
.slot:hover::after {
  content: attr(data-time); position: absolute; top: -1.5rem;
  left: 50%; transform: translateX(-50%);
  background: var(--gray-600); color: var(--white);
  padding: .25rem .5rem; border-radius: var(--radius); font-size: .75rem;
  z-index: 10;
}

/* Hour and minute marks */
.slot.hour-mark {
  font-weight: bold;
  background-color: var(--gray-200);
}
.slot.minute-mark {
  color: var(--gray-600);
}

/* Buttons */
.action-buttons {
  display: flex; gap: 1rem; margin-bottom: 1rem;
  flex-wrap: wrap;
}
.primary-btn, .secondary-btn {
  padding: .75rem 1.5rem; border-radius: var(--radius); cursor: pointer;
  transition: .2s;
}
.primary-btn {
  background: var(--primary); color: var(--white); border: none;
}
.primary-btn:hover {
  background: #1d4ed8;
}
.secondary-btn {
  background: var(--white); color: var(--gray-600); border: 1px solid var(--gray-300);
}
.secondary-btn:hover {
  background: var(--gray-100);
}

/* Calendar Preview */
.calendar-toggle { 
  display: flex; 
  align-items: center; 
  gap: .5rem; 
  margin-bottom: 1rem; 
  justify-content: space-between;
}
.toggle-switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; top:0; left:0; right:0; bottom:0;
  background: var(--gray-300); border-radius: 24px; transition: .4s;
}
.toggle-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px;
  left:3px; bottom:3px; background: var(--white); border-radius:50%;
  transition: .4s;
}
input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider::before { transform: translateX(26px); }

/* Export functionality */
.export-options {
  position: relative;
  margin-left: auto;
}

.export-btn {
  background-color: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.export-btn:hover {
  background-color: var(--gray-100);
}

.export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 100;
  display: none;
}

.export-dropdown.show {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.export-option:hover {
  background-color: var(--gray-100);
}

.export-divider {
  height: 1px;
  background-color: var(--gray-200);
  margin: 0.5rem 0;
}

.calendar-view {
  overflow-x: auto; border: 1px solid var(--gray-300);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.calendar-header, .calendar-body {
  display: grid; grid-template-columns: 80px repeat(7, 1fr);
}
.calendar-header div {
  padding: .5rem; background: var(--gray-200); text-align: center;
  font-weight: bold;
  font-size: 0.85rem;
}
.calendar-header div.today {
  background-color: var(--light);
  color: var(--primary);
}
.calendar-header div.current-edit {
  border-bottom: 2px solid var(--primary);
}
.calendar-body {
  grid-auto-rows: 40px; 
}
.calendar-body div {
  border-top: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
}
.calendar-body .time-label {
  background: var(--gray-100); text-align: right; padding-right: .5rem;
  font-size: .75rem; color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Enhanced calendar cells */
.hour-cell {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  position: relative;
}
.quarter-slot {
  border-bottom: 1px dotted var(--gray-200);
  height: 100%;
}
.quarter-slot:last-child {
  border-bottom: none;
}
.quarter-slot.selected {
  background-color: var(--primary);
  opacity: 0.7;
}

/* Modal styles */
.ai-suggestion-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background-color: white;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-600);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.template-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: var(--primary);
  background-color: var(--light);
}

.template-icon {
  width: 3rem;
  height: 3rem;
  background-color: var(--light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.template-info h4 {
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}

.template-info p {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin: 0;
}

/* Notification styles */
.notification {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 1000;
  animation: slideIn 0.3s ease-out;
}

.save-confirmation {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--success);
  color: white;
  padding: 1rem;
  text-align: center;
  z-index: 1000;
  animation: slideDown 0.3s ease-out;
}

.save-confirmation-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  max-width: 600px;
  margin: 0 auto;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: auto;
}

/* Animations */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

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

/* Accessibility */
button:focus, select:focus, input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Responsive styles */
@media (max-width: 768px) {
  .week-navigation {
    flex-direction: column;
    gap: 1rem;
  }
  
  .week-info-container {
    order: -1;
  }
  
  .controls {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .day-selector {
    width: 100%;
    justify-content: space-between;
  }
  
  .day-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0;
  }
  
  .action-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .primary-btn, .secondary-btn {
    width: 100%;
  }
}
