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

:root {
  --color-bg: #eef1f6;
  --color-surface: #ffffff;
  --color-border: #dde1e7;
  --color-text: #1a1d23;
  --color-text-muted: #6b7280;
  --color-brand: #1a1a2e;
  --color-brand-accent: #4F6AF5;

  --kind-meeting: #4F6AF5;
  --kind-social:  #E67E22;
  --kind-panel:   #9B59B6;
  --kind-hold:    #95A5A6;
  --kind-placeholder: #BDC3C7;
  --kind-block:   #2c3e50;
  --kind-travel:  #78909C;

  --header-h: 108px;
  --time-col-w: 52px;
  --row-h: 36px;   /* 30 min = 36px */
  --col-min-w: 130px;
  --col-max-w: 200px;
  --grid-gap: 1px;
  --event-radius: 6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.4;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0f1128 0%, #1a1a2e 60%, #1e1e38 100%);
  color: white;
  padding: 0 20px;
  box-shadow: 0 2px 16px rgba(0,0,0,.4);
}

.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 0 8px;
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
}
.brand-show { color: white; }
.brand-tell { color: var(--color-brand-accent); }

.brand-by {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  font-weight: 400;
  letter-spacing: .4px;
}
.brand-skai {
  color: rgba(255,255,255,.6);
  font-weight: 600;
}

/* Centered event title */
.header-event-title {
  text-align: center;
  min-width: 0;
}

.event-source {
  font-size: 10px;
  line-height: 1.1;
  color: rgba(255,255,255,.5);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.event-source:hover {
  color: rgba(255,255,255,.85);
  text-decoration: underline;
}
.event-source-info {
  display: inline-block;
  margin-left: 4px;
  opacity: .8;
}

.event-title-text {
  font-size: 15px;
  font-weight: 700;
  color: rgba(255,255,255,.92);
  letter-spacing: .2px;
  white-space: nowrap;
}

.event-switcher-center {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.9);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-align: center;
}

.header-controls {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-icon {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  color: white;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); }
.btn-add { font-size: 22px; font-weight: 300; }

.header-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 0 10px;
  flex-wrap: wrap;
}

.day-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

.day-tab {
  padding: 5px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.8);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.day-tab:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
}
.day-tab.active {
  background: var(--color-brand-accent);
  border-color: var(--color-brand-accent);
  color: white;
  box-shadow: 0 2px 12px rgba(79,106,245,.55);
}

.tab-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
  margin-left: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* Stats bar — hidden */
.stats-bar { display: none !important; }

.stat-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 4px 12px 4px 9px;
  white-space: nowrap;
}

.stat-chip .stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-chip.stat-total {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.22);
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 14px;
}

.offline-banner {
  font-size: 12px;
  color: #ffd166;
  background: rgba(255,209,102,.15);
  padding: 4px 10px;
  border-radius: 4px;
}

.exec-picker-wrap {
  padding: 0 0 8px;
}
.exec-picker {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
  max-width: 280px;
  appearance: auto;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.app-main {
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.grid-scroll {
  height: 100%;
  overflow: auto;
  padding: 12px;
}

/* ── Calendar grid ───────────────────────────────────────────────────────── */
.calendar-grid {
  display: grid;
  border: 1px solid #e2e5ed;
  border-radius: 10px;
  background: transparent;
  overflow: hidden;
  min-width: max-content;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}

/* Header cells */
.grid-header {
  background: #ffffff;
  color: #1a1d23;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: sticky;
  top: 0;
  z-index: 10;
  border-right: 1px solid #e2e5ed;
  border-bottom: 2px solid #e2e5ed;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.grid-header.time-header {
  background: #f5f7fa;
  border-right: 1px solid #e2e5ed;
}

/* Time label cells */
.grid-time {
  background: #f5f7fa;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 500;
  text-align: right;
  padding: 2px 8px 0;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 5;
  border-right: 1px solid #e2e5ed;
}
.grid-time.hour-mark { color: #6b7280; font-weight: 700; }

/* Body cells (one per slot per exec) */
.grid-cell {
  background: #ffffff;
  min-height: var(--row-h);
  border-right: 1px solid #e8ebf2;
  cursor: pointer;
  transition: background-color .12s;
}
.grid-cell:not(.unavailable):hover { background-color: rgba(79,106,245,.08); }
.grid-cell.alt-row { background: #ffffff; }
.grid-cell.hour-boundary { border-top: 1px solid #d1d5e0; }
.grid-cell.unavailable {
  background: repeating-linear-gradient(
    135deg,
    #f2f3f7 0px, #f2f3f7 4px,
    #e8eaef 4px, #e8eaef 8px
  ) !important;
  pointer-events: none;
}

.grid-header.exec-absent {
  opacity: 0.4;
  font-style: italic;
}

/* Availability zone labels (arrival / departure) */
.avail-zone-label {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  position: relative;
  z-index: 3;
}
.avail-zone-label span {
  display: block;
  background: rgba(255,255,255,.88);
  border: 1px solid #d1d5e0;
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 10px;
  line-height: 1.5;
  color: #374151;
  text-align: center;
  white-space: normal;
  max-width: calc(100% - 8px);
}
.avail-zone-label em {
  font-style: normal;
  font-weight: 700;
  color: #1a1d23;
  display: block;
}
.avail-arrives { align-items: flex-end; padding-bottom: 8px; }
.avail-departs { align-items: flex-start; padding-top: 8px; }
.avail-absent  { align-items: center; }

/* ── Event blocks ────────────────────────────────────────────────────────── */
.event-block {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  border-radius: var(--event-radius);
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
  overflow: hidden;
  color: white;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: filter .12s, box-shadow .12s;
  z-index: 2;
}
.event-block:hover {
  filter: brightness(1.08);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  z-index: 3;
}

.event-block .ev-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.event-block .ev-company {
  font-size: 10px;
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-block .ev-loc {
  font-size: 10px;
  opacity: .75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kind-meeting     { background: var(--kind-meeting); }
.kind-social      { background: var(--kind-social); }
.kind-panel       { background: var(--kind-panel); }
.kind-hold        { background: var(--kind-hold); }
.kind-placeholder { background: var(--kind-placeholder); color: #555; }
.kind-block       { background: var(--kind-block); }
.kind-travel      { background: var(--kind-travel); opacity: .85; }

/* ── Legend ──────────────────────────────────────────────────────────────── */
.legend {
  position: fixed;
  bottom: 12px;
  right: 16px;
  display: flex;
  gap: 10px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  z-index: 50;
}
.legend-item { display: flex; align-items: center; gap: 4px; color: var(--color-text-muted); }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.kind-meeting     { background: var(--kind-meeting); }
.dot.kind-social      { background: var(--kind-social); }
.dot.kind-panel       { background: var(--kind-panel); }
.dot.kind-hold        { background: var(--kind-hold); }
.dot.kind-block       { background: var(--kind-block); }
.dot.kind-travel      { background: var(--kind-travel); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: white;
  border-radius: 14px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.modal-close:hover { background: #f0f0f0; }

/* Event detail */
.event-detail-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  padding-right: 30px;
}
.event-detail-meta {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-meeting     { background: #EBF0FF; color: var(--kind-meeting); }
.badge-social      { background: #FEF3E8; color: var(--kind-social); }
.badge-panel       { background: #F5EBF9; color: var(--kind-panel); }
.badge-hold        { background: #F0F3F4; color: #555; }
.badge-placeholder { background: #F5F5F5; color: #888; }
.badge-block       { background: #eee; color: #333; }

.detail-section { margin-bottom: 12px; }
.detail-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.detail-section p {
  font-size: 13px;
  color: var(--color-text);
}

.attendee-list { list-style: none; }
.attendee-list li {
  font-size: 13px;
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rsvp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rsvp-accepted  { background: #2ecc71; }
.rsvp-declined  { background: #e74c3c; }
.rsvp-tentative { background: #f39c12; }
.rsvp-needsAction { background: #bdc3c7; }

.comment-box {
  margin-top: 12px;
  padding: 8px 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
}
.comment-box strong { display: block; font-size: 11px; margin-bottom: 2px; }

textarea.comment-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  margin-top: 6px;
}

/* Modal form */
.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}
.modal-form label input,
.modal-form label select,
.modal-form label textarea {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: white;
}
.modal-form label input:focus,
.modal-form label select:focus { outline: 2px solid var(--color-brand-accent); }
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }
.optional { font-weight: 400; font-size: 11px; }
.exec-checkboxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-top: 6px;
}
.exec-checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  color: #374151;
}
.exec-checkboxes input[type="checkbox"] { margin: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-primary {
  flex: 1;
  padding: 10px;
  background: var(--color-brand-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  flex: 1;
  padding: 10px;
  background: white;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-brand-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-day {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: 14px;
}

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

/* Shared mobile header tweaks */
@media (max-width: 900px) {
  .header-top { grid-template-columns: auto 1fr auto; gap: 8px; }
  .brand-name { font-size: 15px; }
  .event-title-text, .event-switcher-center { font-size: 13px; }
  .legend {
    bottom: 8px;
    right: 8px;
    left: 8px;
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Phone-sized: drop the brand block so the event title gets the full width */
@media (max-width: 600px) {
  .header-brand { display: none; }
  .header-top { grid-template-columns: 1fr auto; }
  .btn-icon { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
  .btn-add { font-size: 20px; }
  .header-controls { gap: 6px; }
}

/* Portrait mobile — heatmap: ~39px cols, color bars only, no text */
@media (max-width: 500px) {
  :root { --row-h: 28px; }
  .app-main { height: calc(100vh - 108px); }
  .calendar-grid { min-width: 100%; }
  .grid-time { font-size: 8px; padding: 1px 3px 0; }
  .grid-header { font-size: 9px; padding: 6px 2px; }
  .event-block .ev-title,
  .event-block .ev-company,
  .event-block .ev-loc { display: none; }
  .avail-zone-label { display: none; }
}

/* Landscape mobile — wider cols, text reappears */
@media (min-width: 501px) and (max-width: 900px) {
  :root { --row-h: 32px; }
  .app-main { height: calc(100vh - 108px); }
  .calendar-grid { min-width: 100%; }
  .grid-time { font-size: 9px; }
  .grid-header { font-size: 10px; padding: 6px 3px; }
  .avail-zone-label { display: none; }
}
