:root {
  --bg-dark: #0f111a;
  --bg-glass: rgba(30, 33, 48, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  
  --text-main: #ffffff;
  --text-muted: #8e95ad;
  --text-inverse: #0f111a;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #ec4899;
  
  --available-bg: rgba(99, 102, 241, 0.15);
  --available-border: rgba(99, 102, 241, 0.4);
  --available-text: #818cf8;
  
  --booked-bg: rgba(236, 72, 153, 0.15);
  --booked-border: rgba(236, 72, 153, 0.4);
  --booked-text: #f472b6;
  
  --selected-bg: #6366f1;
  --selected-text: #ffffff;
  
  --orb-1: #6366f1;
  --orb-2: #ec4899;
  --orb-3: #8b5cf6;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Background Animated Orbs */
.background-orbs {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background-color: var(--orb-1);
  animation-delay: 0s;
}

.orb-2 {
  bottom: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background-color: var(--orb-2);
  animation-delay: -5s;
}

.orb-3 {
  top: 40%;
  left: 50%;
  width: 40vw;
  height: 40vw;
  background-color: var(--orb-3);
  animation-delay: -10s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(100px, -50px) scale(1.1); }
}

/* Main Layout */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  width: 95%;
  height: 85vh;
  max-height: 800px;
}

.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  padding: 2.5rem;
}

/* Sidebar */
.sidebar {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
}

.sidebar-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header .subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* Toggle Switch */
.mode-toggle-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #374151;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.mode-label {
  font-weight: 600;
  font-size: 1.1rem;
}

.mode-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

/* Selection Panel */
.selection-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.selection-panel h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  font-weight: 500;
  flex-shrink: 0;
}

.selected-dates-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  padding-right: 0.5rem;
  min-height: 0;
}

/* Custom Scrollbar */
.selected-dates-list::-webkit-scrollbar {
  width: 6px;
}
.selected-dates-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
}
.selected-dates-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.95rem;
}

.date-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.date-item button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.date-item button:hover {
  color: #ef4444;
}

.action-btn {
  background: var(--primary);
  color: var(--text-main);
  border: none;
  padding: 1rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.action-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.action-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* Warning Modal Additions */
.modal-content.warning h2 {
  color: #ff4b4b;
}

/* Network Loader Overlay */
#network-loader {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 11, 26, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  font-weight: 500;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* Calendar Section */
.calendar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.calendar-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.calendar-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(70px, 1fr);
  gap: 0.5rem;
  flex: 1;
}

.day {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 70px;
}

.day.empty {
  background: none;
  cursor: default;
}

.day:not(.empty):hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.day-name {
  font-size: 0.70rem;
  font-weight: 400;
  margin-top: auto;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
  z-index: 2;
  margin-bottom: 2px;
}

/* Day States */
.day.available {
  background: var(--available-bg);
  border-color: var(--available-border);
  color: var(--available-text);
}

.day.past {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

.day.booked {
  background: var(--booked-bg);
  border-color: var(--booked-border);
  color: var(--booked-text);
}

.day.booked:hover {
  /* Allow hover effect for editing in friend/owner mode */
  transform: translateY(-2px);
}

.day.selected {
  background: var(--selected-bg);
  border-color: var(--primary);
  color: var(--selected-text);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
  transform: scale(1.02);
}

/* Status Indicator Dots */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.day.available .status-dot {
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.day.booked .status-dot {
  background-color: var(--secondary);
  box-shadow: 0 0 8px var(--secondary);
}

.day.selected .status-dot {
  display: none;
}

/* Inside day span */
.day-num {
  z-index: 2;
}

/* Legend */
.legend {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.legend-color.available {
  background: var(--available-text);
}
.legend-color.booked {
  background: var(--booked-text);
}
.legend-color.selected {
  background: var(--selected-bg);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 400px;
  z-index: 101;
  display: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 2rem;
}

.modal.show, .modal-overlay.show {
  display: block;
}

.modal.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-overlay.active {
  opacity: 1;
}

.modal-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.input-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.input-group input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--primary);
}

.input-group input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

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

.btn-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  transition: color 0.2s;
}

.btn-cancel:hover {
  color: white;
}

.btn-confirm {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

.btn-danger {
  background: #ef4444;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(30, 33, 48, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  padding: 1rem 2rem;
  border-radius: 30px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 900px) {
  body {
    align-items: flex-start;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-container {
    flex-direction: column;
    height: auto;
    max-height: none;
    margin: 1rem 0;
    width: 100%;
    padding: 0 0.5rem;
    gap: 1rem;
  }

  .glass-panel {
    padding: 1.5rem;
    border-radius: 16px;
  }

  .sidebar {
    flex: none;
  }

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

  .mode-description {
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
  }

  .selected-dates-list {
    max-height: 120px;
  }

  .calendar-section {
    min-height: auto;
  }

  .calendar-header {
    margin-bottom: 1rem;
  }

  .calendar-header h2 {
    font-size: 1.2rem;
  }

  .days {
    grid-auto-rows: minmax(48px, 1fr);
    gap: 0.25rem;
  }

  .day {
    min-height: 48px;
    padding: 0.3rem;
    border-radius: 8px;
    font-size: 0.85rem;
  }

  .day-name {
    font-size: 0.6rem;
  }

  .status-dot {
    width: 4px;
    height: 4px;
    bottom: 4px;
  }

  .weekdays {
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
  }

  .legend {
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    flex-wrap: wrap;
  }

  .legend-item {
    font-size: 0.8rem;
  }

  .nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }

  .modal {
    width: 94%;
    padding: 1.5rem;
  }

  .modal-actions {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .toast {
    bottom: 16px;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    max-width: 90vw;
  }
}

@media (max-width: 400px) {
  .glass-panel {
    padding: 1rem;
  }

  .sidebar-header h1 {
    font-size: 1.3rem;
  }

  .days {
    grid-auto-rows: minmax(40px, 1fr);
    gap: 2px;
  }

  .day {
    min-height: 40px;
    padding: 0.2rem;
    border-radius: 6px;
    font-size: 0.8rem;
  }

  .day-name {
    font-size: 0.55rem;
  }

  .edit-modal .modal-actions {
    flex-direction: column;
  }
}
