/* =====================================================
   cal.tiltay.fr — Modern Light Theme
   ===================================================== */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --today-bg: #eff6ff;
  --today-border: #3b82f6;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --topbar-h: 56px;
  --font: 'Inter', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ── Topbar ──────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; flex: 0 0 200px; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.brand-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  letter-spacing: -.02em;
}
.brand-icon em { color: #fbbf24; font-style: normal; }

/* ── Nav controls ────────────────────────────────── */

.nav-period {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-2);
  transition: background .15s;
}
.nav-arrow:hover { background: var(--surface-2); color: var(--text); }
.nav-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  min-width: 200px;
  text-align: center;
}
.nav-today {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
}
.nav-today:hover { border-color: var(--primary); color: var(--primary); }

/* ── View switcher ───────────────────────────────── */

.view-switcher {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.view-btn {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
}
.view-btn:hover { color: var(--text); background: var(--border-light); }
.view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ── Buttons ─────────────────────────────────────── */

.btn-new {
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
  white-space: nowrap;
}
.btn-new:hover { background: var(--primary-dark); }

.btn-logout {
  padding: 6px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
}
.btn-logout:hover { border-color: var(--text-2); color: var(--text); }

.logout-form { margin: 0; }

.date-jump-input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-2);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s;
  width: 130px;
}
.date-jump-input:focus { outline: none; border-color: var(--primary); }

.btn-primary {
  display: inline-flex; align-items: center;
  padding: 9px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.full-width { width: 100%; justify-content: center; }

.btn-outline {
  display: inline-flex; align-items: center;
  padding: 9px 20px;
  background: none;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
  text-decoration: none;
}
.btn-outline:hover { border-color: var(--text-2); color: var(--text); }

.btn-danger {
  display: inline-flex; align-items: center;
  padding: 9px 20px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background .15s;
}
.btn-danger:hover { background: #dc2626; }

.btn-danger-outline {
  display: inline-flex; align-items: center;
  padding: 6px 14px;
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  transition: all .15s;
  text-decoration: none;
}
.btn-danger-outline:hover { background: var(--danger-light); }

/* ── Main content ────────────────────────────────── */

.main-content {
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ── Month view ──────────────────────────────────── */

.month-grid {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.month-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}
.month-header-cell {
  padding: 8px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.month-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 0 8px 8px;
  gap: 4px;
}

.month-week {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  min-height: 0;
}

.month-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  min-height: 80px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s;
}
.month-day:hover { border-color: var(--primary); }
.month-day.other-month { background: var(--surface-2); }
.month-day.today {
  background: var(--today-bg);
  border-color: var(--today-border);
}

.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: 50%;
  transition: background .1s;
}
.day-number:hover { background: var(--border); }
.today-number {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.today-number:hover { background: var(--primary-dark); }

.day-add-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.month-day:hover .day-add-btn { opacity: 1; }
.day-add-btn:hover { background: var(--border); color: var(--primary); }

.day-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

/* ── Event pill ──────────────────────────────────── */

.event-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  background: color-mix(in srgb, var(--event-color) 15%, transparent);
  color: color-mix(in srgb, var(--event-color) 70%, #1e293b);
  border-left: 2px solid var(--event-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s;
  cursor: pointer;
}
.event-pill:hover {
  background: color-mix(in srgb, var(--event-color) 25%, transparent);
}
.event-pill.imported {
  opacity: 0.85;
  border-style: dashed;
}
.pill-time {
  font-weight: 600;
  opacity: .8;
  flex-shrink: 0;
}

.more-link {
  font-size: 11px;
  color: var(--text-3);
  padding: 0 6px;
  transition: color .1s;
}
.more-link:hover { color: var(--primary); }

/* ── Week / Day grid ─────────────────────────────── */

.week-container,
.day-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.week-header-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.week-day-header-cell {
  flex: 1;
  border-left: 1px solid var(--border-light);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.week-day-header-cell a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.week-day-header-cell.today-header .day-abbr { color: var(--primary); }

.week-allday-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: 32px;
  flex-shrink: 0;
}
.allday-label-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.week-allday-col {
  flex: 1;
  padding: 4px;
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.week-scroll,
.day-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.week-grid,
.day-grid {
  display: flex;
  height: var(--total-height);
  position: relative;
}

.time-gutter {
  width: 44px;
  flex-shrink: 0;
  position: relative;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.time-slot-label {
  position: absolute;
  right: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  transform: translateY(-50%);
  white-space: nowrap;
  user-select: none;
}

.week-day-col,
.day-col {
  flex: 1;
  border-left: 1px solid var(--border-light);
  position: relative;
  background: var(--surface);
}
.week-day-col.today-col,
.day-col.today-col { background: var(--today-bg); }

.week-day-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: inherit;
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.week-day-header a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.day-abbr {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.day-num {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .1s;
}
.week-day-header:hover .day-num { background: var(--border); }
.today-bubble {
  background: var(--primary);
  color: #fff;
}
.today-header .day-abbr { color: var(--primary); }

.week-day-body {
  position: relative;
  overflow: hidden;
}

.hour-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--border-light);
  pointer-events: none;
}

/* ── Timed event block ───────────────────────────── */

.week-event {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: color-mix(in srgb, var(--event-color) 18%, white);
  border-left: 3px solid var(--event-color);
  transition: filter .1s;
  z-index: 1;
}
.week-event:hover { filter: brightness(.94); }
.week-event.imported { border-style: dashed; }
.we-title {
  font-size: 12px;
  font-weight: 600;
  color: color-mix(in srgb, var(--event-color) 60%, #1e293b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.we-time {
  font-size: 10px;
  color: color-mix(in srgb, var(--event-color) 50%, #475569);
  white-space: nowrap;
}

/* ── Day view specific ───────────────────────────── */

.day-allday-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.allday-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  width: 44px;
}
.allday-events { display: flex; flex-wrap: wrap; gap: 4px; }

.day-col {
  flex: 1;
}

.empty-day {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Event form ──────────────────────────────────── */

.form-page {
  padding: 32px 16px;
  display: flex;
  justify-content: center;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-md);
}
.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.form-card h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.event-form { display: flex; flex-direction: column; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.form-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  width: 100%;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
textarea.form-input { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-inline { flex-direction: row; align-items: center; gap: 8px; }
.form-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.form-color { width: 48px; height: 36px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }
.form-color-row { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
.color-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.color-preset-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform .1s;
}
.color-preset-btn:hover { transform: scale(1.2); }
.form-error { font-size: 12px; color: var(--danger); }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* Event detail (imported) */
.event-detail-header {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: flex-start;
}
.event-detail-color-bar {
  width: 4px;
  min-height: 48px;
  border-radius: 2px;
  background: var(--event-color);
  flex-shrink: 0;
}
.event-detail-body h1 { font-size: 20px; font-weight: 700; }
.event-detail-source {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.event-detail-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}
.detail-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--text-2);
}
.detail-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.detail-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  background: var(--surface-2);
  border-radius: 100px;
  font-size: 11px;
  color: var(--text-3);
}

/* Delete confirm */
.delete-info {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 20px 0;
  line-height: 1.8;
}
.delete-warning {
  font-size: 13px;
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 16px;
}

/* ── Login ───────────────────────────────────────── */

.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-logo {
  width: 52px; height: 52px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 auto 16px;
}
.login-logo em { color: #fbbf24; font-style: normal; }
.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.login-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 28px;
}
.login-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.login-error {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

/* ── Responsive ──────────────────────────────────── */

@media (max-width: 768px) {
  .topbar-left .brand-name { display: none; }
  .nav-label { font-size: 13px; min-width: 140px; }
  .view-btn { padding: 4px 8px; font-size: 12px; }
  .btn-new { padding: 6px 10px; font-size: 12px; }
  .btn-logout { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .month-header-cell { font-size: 10px; }
  .event-pill { font-size: 10px; }
}

@media (max-width: 480px) {
  .week-allday-row, .week-allday-col { display: none; }
}
