/* =====================================================
   Calendar App — Global Styles
   Theme: Dark Glassmorphism + Purple/Cyan accent
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  --bg-from: #0f0c29;
  --bg-mid:  #1a1640;
  --bg-to:   #24243e;

  --glass-bg:     rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.12);
  --glass-hover:  rgba(255,255,255,0.10);
  --glass-active: rgba(255,255,255,0.14);

  --primary:       #7c3aed;
  --primary-light: #a78bfa;
  --primary-dark:  #5b21b6;
  --cyan:          #06b6d4;
  --cyan-light:    #67e8f9;

  --status-free:      rgba(100,116,139,0.6);
  --status-free-text: #94a3b8;
  --status-confirmed:      rgba(16,185,129,0.25);
  --status-confirmed-border: #10b981;
  --status-confirmed-text:   #6ee7b7;
  --status-invited:      rgba(245,158,11,0.25);
  --status-invited-border: #f59e0b;
  --status-invited-text:   #fcd34d;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --border-radius: 16px;
  --border-radius-sm: 8px;
  --transition: 0.2s ease;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(135deg, var(--bg-from), var(--bg-mid), var(--bg-to));
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 3px; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Navbar ── */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(15,12,41,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  user-select: none;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-right: 8px;
}

.nav-logo svg { flex-shrink: 0; }

.nav-divider { width: 1px; height: 28px; background: var(--glass-border); }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: var(--primary-light);
}

.nav-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 16px rgba(124,58,237,0.4);
}

.nav-btn.today-btn {
  background: linear-gradient(135deg, var(--cyan), #0891b2);
  border-color: var(--cyan);
  color: #fff;
  box-shadow: 0 0 12px rgba(6,182,212,0.3);
}

.nav-btn.today-btn:hover {
  box-shadow: 0 0 20px rgba(6,182,212,0.5);
}

.nav-btn.icon-btn {
  padding: 7px 10px;
}

.nav-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 200px;
  text-align: center;
}

.nav-spacer { flex: 1; }

.nav-btn.create-btn {
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 16px rgba(124,58,237,0.3);
}

.nav-btn.create-btn:hover {
  box-shadow: 0 0 24px rgba(124,58,237,0.5);
  transform: translateY(-1px);
}

/* ── Main Content ── */
#main-content { flex: 1; display: flex; flex-direction: column; padding: 20px 24px; gap: 16px; }

/* ── Legend ── */
#legend {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  backdrop-filter: blur(8px);
}

.legend-label { color: var(--text-muted); font-weight: 500; margin-right: 4px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.free      { background: var(--status-free-text); }
.legend-dot.confirmed { background: var(--status-confirmed-border); }
.legend-dot.invited   { background: var(--status-invited-border); }

/* ── Week View ── */
#week-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
  min-height: 0;
}

.week-header {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}

.week-header-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  border-left: 1px solid var(--glass-border);
}

.week-header-cell:first-child { border-left: none; }

.week-header-day {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.week-header-date {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.week-header-cell.today .week-header-date {
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(6,182,212,0.5);
}

.week-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.week-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  position: relative;
}

.time-label-col { position: relative; }

.time-label {
  height: 30px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-right: 8px;
  padding-top: 2px;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-top: 1px solid transparent;
  position: relative;
  top: -1px;
}

.day-col {
  position: relative;
  border-left: 1px solid var(--glass-border);
  cursor: crosshair;
}

.time-slot {
  height: 30px;
  border-top: 1px solid rgba(255,255,255,0.04);
  position: relative;
  transition: background var(--transition);
}

.time-slot.hour-start {
  border-top-color: rgba(255,255,255,0.09);
}

.time-slot:hover {
  background: rgba(124,58,237,0.08);
}

/* Drag selection */
.day-col.selecting .time-slot.selected {
  background: rgba(124,58,237,0.25);
  border-color: rgba(124,58,237,0.3);
}

.selection-overlay {
  position: absolute;
  left: 2px;
  right: 2px;
  background: linear-gradient(135deg, rgba(124,58,237,0.35), rgba(6,182,212,0.25));
  border: 1.5px solid var(--primary-light);
  border-radius: 6px;
  pointer-events: none;
  z-index: 5;
}

/* Appointment blocks */
.appt-block {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.72rem;
  font-weight: 500;
  overflow: hidden;
  cursor: pointer;
  z-index: 4;
  transition: all var(--transition);
  border-left: 3px solid;
}

.appt-block:hover {
  transform: scaleX(0.97);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 6;
}

.appt-block.free {
  background: var(--status-free);
  border-color: var(--status-free-text);
  color: var(--status-free-text);
}

.appt-block.confirmed {
  background: var(--status-confirmed);
  border-color: var(--status-confirmed-border);
  color: var(--status-confirmed-text);
}

.appt-block.invited {
  background: var(--status-invited);
  border-color: var(--status-invited-border);
  color: var(--status-invited-text);
}

.appt-block-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-block-time {
  font-size: 0.65rem;
  opacity: 0.8;
}

/* ── Month View ── */
#month-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--glass-border);
}

.month-weekday {
  padding: 10px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.month-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

.month-cell {
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  padding: 8px;
  min-height: 90px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
}

.month-cell:nth-child(7n) { border-right: none; }
.month-cell:nth-last-child(-n+7) { border-bottom: none; }

.month-cell:hover { background: var(--glass-hover); }

.month-cell.other-month { opacity: 0.4; }

.month-cell.today { background: rgba(6,182,212,0.07); }
.month-cell.today .month-date { color: var(--cyan); font-weight: 700; }

.month-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.month-cell.today .month-date {
  background: var(--cyan);
  color: #fff;
  text-shadow: none;
}

.month-appts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.month-appt-pill {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity var(--transition);
}

.month-appt-pill:hover { opacity: 0.8; }

.month-appt-pill.free {
  background: rgba(100,116,139,0.3);
  color: var(--status-free-text);
}

.month-appt-pill.confirmed {
  background: rgba(16,185,129,0.2);
  color: var(--status-confirmed-text);
}

.month-appt-pill.invited {
  background: rgba(245,158,11,0.2);
  color: var(--status-invited-text);
}

.month-more {
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 1px 4px;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: linear-gradient(135deg, rgba(26,22,64,0.95), rgba(36,36,62,0.95));
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.25s ease;
  overflow: hidden;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--glass-border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  width: 30px; height: 30px;
  border: none;
  background: var(--glass-bg);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover { background: rgba(239,68,68,0.2); color: #f87171; }

.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select, .form-textarea {
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary-light);
  background: rgba(124,58,237,0.08);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.form-select { cursor: pointer; }
.form-select option { background: #1a1640; }

.form-textarea { resize: vertical; min-height: 70px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--glass-border);
}

.btn {
  padding: 9px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all var(--transition);
}

.btn-ghost {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

.btn-ghost:hover { background: var(--glass-hover); color: var(--text-primary); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #f87171;
}

.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 0 12px rgba(124,58,237,0.3);
}

.btn-primary:hover { box-shadow: 0 0 20px rgba(124,58,237,0.5); transform: translateY(-1px); }

/* ── Status select colors ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-badge.free      { background: rgba(100,116,139,0.2); color: var(--status-free-text); }
.status-badge.confirmed { background: var(--status-confirmed); color: var(--status-confirmed-text); }
.status-badge.invited   { background: var(--status-invited); color: var(--status-invited-text); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  animation: toastIn 0.3s ease;
  max-width: 300px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.success {
  background: rgba(16,185,129,0.2);
  border-color: var(--status-confirmed-border);
  color: var(--status-confirmed-text);
}

.toast.error {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
  color: #f87171;
}

/* ── Loading ── */
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: auto;
}

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

/* ── Current time line ── */
.current-time-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  z-index: 8;
  pointer-events: none;
}

.current-time-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #navbar { padding: 10px 12px; gap: 6px; }
  .nav-title { min-width: 140px; font-size: 0.9rem; }
  #main-content { padding: 12px; }
  .form-row { grid-template-columns: 1fr; }
}
