/*
  AAC AI Schedule Modal — V104.1 Tier 3.2
  Brand Identity Lock:
    - Light surfaces (#FBFBF6 / #FFFFFF / cream alternation)
    - Navy #19195F = section accent only (headers, borders, text)
    - Gold #C9A84C = AI badges, highlights, primary CTA
    - Translucent navy backdrop only — NO heavy navy washes inside the card
  Fonts: Playfair Display (numbers / titles), Montserrat (body)
*/

:root {
  --aac-sched-bg-cream:  #FBFBF6;
  --aac-sched-bg-white:  #FFFFFF;
  --aac-sched-row-alt:   #FDFCF4;
  --aac-sched-navy:      #19195F;
  --aac-sched-navy-soft: #4B4B7A;
  --aac-sched-gold:      #C9A84C;
  --aac-sched-gold-soft: #fff8e1;
  --aac-sched-gold-deep: #b8983f;
  --aac-sched-text:      #2d2d3f;
  --aac-sched-muted:     #6B7280;
  --aac-sched-line:      #e5e7eb;
  --aac-sched-line-soft: #f3f4f6;
  --aac-sched-warn-bg:   #FFFBEA;
  --aac-sched-warn-bd:   #F5D871;
  --aac-sched-warn-tx:   #8a6d1c;
  --aac-sched-err-bg:    #FEF2F2;
  --aac-sched-err-bd:    #FCA5A5;
  --aac-sched-err-tx:    #B91C1C;
  --aac-sched-spring:    cubic-bezier(0.32, 1, 0.55, 1);
}

/* ─── Modal shell ─────────────────────────────────────────── */

.aac-sched-modal[hidden] { display: none; }
.aac-sched-modal {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Montserrat', sans-serif;
  color: var(--aac-sched-text);
}

.aac-sched-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(25, 25, 95, 0.35);
  backdrop-filter: blur(6px);
}

.aac-sched-modal-card {
  position: relative;
  background: var(--aac-sched-bg-white);
  border-radius: 16px;
  box-shadow: 0 25px 80px rgba(25, 25, 95, 0.25);
  max-width: 880px;
  width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: aac-sched-in .35s var(--aac-sched-spring);
}

@keyframes aac-sched-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ─── Header ─────────────────────────────────────────────── */

.aac-sched-header {
  padding: 20px 28px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--aac-sched-line);
  background: linear-gradient(180deg, var(--aac-sched-bg-cream) 0%, var(--aac-sched-bg-white) 100%);
}

.aac-sched-header-meta { min-width: 0; flex: 1; }

.aac-sched-ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--aac-sched-gold-soft);
  color: var(--aac-sched-gold-deep);
  border: 1px solid var(--aac-sched-gold);
  margin-bottom: 8px;
}
.aac-sched-ai-pill-edit {
  background: #eef0fa;
  color: var(--aac-sched-navy);
  border-color: var(--aac-sched-navy);
}
.aac-sched-ai-pill .aac-ic { width: 12px; height: 12px; }

.aac-sched-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--aac-sched-navy);
  font-weight: 700;
  margin: 0;
  line-height: 1.15;
}

.aac-sched-subtitle {
  font-size: 13px;
  color: var(--aac-sched-muted);
  margin: 4px 0 0;
}

.aac-sched-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 26px;
  color: var(--aac-sched-muted);
  line-height: 1;
  padding: 4px 10px;
  border-radius: 8px;
  transition: background .15s ease;
}
.aac-sched-close:hover { background: var(--aac-sched-line-soft); }

/* ─── Stats ─────────────────────────────────────────────── */

.aac-sched-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 16px 28px;
  background: var(--aac-sched-bg-cream);
  border-bottom: 2px solid var(--aac-sched-gold);
}

.aac-sched-stat {
  text-align: center;
  padding: 4px 8px;
  border-right: 1px solid var(--aac-sched-line);
}
.aac-sched-stat:last-child { border-right: none; }

.aac-sched-stat-num {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--aac-sched-gold-deep);
  line-height: 1.1;
}

.aac-sched-stat-label {
  font-size: 10px;
  color: var(--aac-sched-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 4px;
  font-weight: 600;
}

/* ─── Phases (Gantt-lite) ──────────────────────────────── */

.aac-sched-phases {
  flex: 1;
  overflow-y: auto;
  padding: 8px 28px 16px;
  background: var(--aac-sched-bg-white);
}

.aac-sched-phase {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 12px 12px 12px 0;
  border-radius: 8px;
  position: relative;
  background: var(--aac-sched-bg-white);
  transition: background .15s ease;
}
.aac-sched-phase:nth-child(even) {
  background: var(--aac-sched-row-alt);
}
.aac-sched-phase + .aac-sched-phase { margin-top: 2px; }

/* Active phase indicator (gold left border) */
.aac-sched-phase.is-active {
  border-left: 3px solid var(--aac-sched-gold);
  padding-left: 9px;
}
.aac-sched-phase-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--aac-sched-navy);
  margin-top: 18px;
  margin-left: 3px;
  position: relative;
  flex-shrink: 0;
}
.aac-sched-phase.is-milestone .aac-sched-phase-marker {
  background: var(--aac-sched-gold);
  border: 2px solid var(--aac-sched-bg-white);
  box-shadow: 0 0 0 2px var(--aac-sched-gold);
}

.aac-sched-phase-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.aac-sched-phase-row1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.aac-sched-phase-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--aac-sched-navy);
  margin: 0;
}

.aac-sched-phase-dates {
  font-size: 12px;
  color: var(--aac-sched-muted);
  font-weight: 500;
  white-space: nowrap;
}

.aac-sched-phase-row2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--aac-sched-navy-soft);
  flex-wrap: wrap;
}

.aac-sched-phase-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--aac-sched-gold-soft);
  color: var(--aac-sched-gold-deep);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
}

.aac-sched-phase-duration {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.aac-sched-phase-deps {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--aac-sched-muted);
  letter-spacing: 0.4px;
}

/* Dependency arrow (thin gray) */
.aac-sched-phase-deps::before {
  content: "↳";
  color: var(--aac-sched-muted);
  font-size: 13px;
  margin-right: 2px;
}

.aac-sched-phase-bar-wrap {
  position: relative;
  height: 8px;
  background: var(--aac-sched-line-soft);
  border-radius: 4px;
  margin-top: 4px;
  overflow: hidden;
}
.aac-sched-phase-bar {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--aac-sched-navy) 0%, var(--aac-sched-navy-soft) 100%);
  border-radius: 4px;
  transition: width .25s var(--aac-sched-spring);
}
.aac-sched-phase.is-milestone .aac-sched-phase-bar {
  background: var(--aac-sched-gold);
  width: 6px !important;
  left: 0;
}

.aac-sched-phase-notes {
  font-size: 12px;
  color: var(--aac-sched-text);
  margin: 6px 0 0;
  line-height: 1.45;
  padding: 8px 10px;
  border-left: 2px solid var(--aac-sched-gold);
  background: var(--aac-sched-gold-soft);
  border-radius: 0 6px 6px 0;
}

/* ─── Warnings ─────────────────────────────────────────── */

.aac-sched-warnings {
  margin: 0 28px 12px;
  padding: 14px 16px;
  background: var(--aac-sched-warn-bg);
  border: 1px solid var(--aac-sched-warn-bd);
  border-left: 4px solid var(--aac-sched-warn-bd);
  border-radius: 8px;
}
.aac-sched-warnings-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--aac-sched-warn-tx);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.aac-sched-warnings-list {
  margin: 0;
  padding-left: 22px;
  font-size: 12px;
  color: var(--aac-sched-warn-tx);
  line-height: 1.6;
}

/* ─── Footer ───────────────────────────────────────────── */

.aac-sched-footer {
  padding: 16px 28px;
  background: var(--aac-sched-bg-cream);
  border-top: 1px solid var(--aac-sched-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.aac-sched-footer-primary {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.aac-sched-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  background: transparent;
  color: var(--aac-sched-navy);
  line-height: 1;
}

.aac-sched-btn-ghost {
  background: var(--aac-sched-bg-white);
  border-color: var(--aac-sched-line);
  color: var(--aac-sched-navy);
}
.aac-sched-btn-ghost:hover {
  border-color: var(--aac-sched-navy);
  background: var(--aac-sched-bg-cream);
  transform: translateY(-1px);
}

.aac-sched-btn-tertiary {
  background: transparent;
  color: var(--aac-sched-navy-soft);
  font-size: 12px;
  padding: 8px 12px;
}
.aac-sched-btn-tertiary:hover { color: var(--aac-sched-navy); }

.aac-sched-btn-primary {
  background: var(--aac-sched-gold);
  border-color: var(--aac-sched-gold);
  color: white;
  box-shadow: 0 2px 10px rgba(201, 168, 76, 0.3);
}
.aac-sched-btn-primary:hover {
  background: var(--aac-sched-gold-deep);
  border-color: var(--aac-sched-gold-deep);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.4);
}

.aac-sched-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─── Loading state ────────────────────────────────────── */

.aac-sched-loading {
  padding: 60px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.aac-sched-loading-spark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--aac-sched-gold-soft);
  border: 2px solid var(--aac-sched-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: aac-sched-spark 2s var(--aac-sched-spring) infinite;
}
.aac-sched-loading-spark .aac-ic {
  width: 28px;
  height: 28px;
  color: var(--aac-sched-gold-deep);
}
@keyframes aac-sched-spark {
  0%, 100% { transform: scale(1) rotate(0deg);   box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4); }
  50%      { transform: scale(1.08) rotate(8deg); box-shadow: 0 0 0 12px rgba(201, 168, 76, 0); }
}

.aac-sched-loading-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--aac-sched-navy);
  font-weight: 700;
  margin: 0;
}
.aac-sched-loading-sub {
  font-size: 13px;
  color: var(--aac-sched-muted);
  margin: 0;
  max-width: 380px;
  line-height: 1.5;
}

/* ─── Edit grid ────────────────────────────────────────── */

.aac-sched-edit-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px 28px 16px;
}

.aac-sched-edit-row {
  display: grid;
  grid-template-columns: 1.7fr 1fr 100px 1.3fr;
  gap: 12px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--aac-sched-line-soft);
}
.aac-sched-edit-row:last-child { border-bottom: none; }
.aac-sched-edit-row:nth-child(odd) {
  background: var(--aac-sched-row-alt);
  border-radius: 6px;
}

.aac-sched-edit-row-name {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--aac-sched-navy);
  font-size: 14px;
}

.aac-sched-edit-input {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--aac-sched-line);
  border-radius: 6px;
  background: var(--aac-sched-bg-white);
  color: var(--aac-sched-text);
  width: 100%;
}
.aac-sched-edit-input:focus {
  outline: none;
  border-color: var(--aac-sched-gold);
  box-shadow: 0 0 0 3px var(--aac-sched-gold-soft);
}

.aac-sched-edit-grid-headers {
  display: grid;
  grid-template-columns: 1.7fr 1fr 100px 1.3fr;
  gap: 12px;
  padding: 8px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--aac-sched-muted);
  border-bottom: 2px solid var(--aac-sched-gold);
  margin-bottom: 4px;
}

/* ─── Error state ──────────────────────────────────────── */

.aac-sched-error {
  padding: 60px 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.aac-sched-error-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--aac-sched-err-bg);
  border: 2px solid var(--aac-sched-err-bd);
  color: var(--aac-sched-err-tx);
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.aac-sched-error-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: var(--aac-sched-navy);
  margin: 0;
}
.aac-sched-error-msg {
  font-size: 13px;
  color: var(--aac-sched-muted);
  margin: 0;
  max-width: 420px;
  line-height: 1.5;
}

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

@media (max-width: 740px) {
  .aac-sched-modal-card { max-height: calc(100vh - 16px); }
  .aac-sched-stats { grid-template-columns: repeat(2, 1fr); }
  .aac-sched-stat:nth-child(2) { border-right: none; }
  .aac-sched-edit-row,
  .aac-sched-edit-grid-headers {
    grid-template-columns: 1fr 1fr;
  }
  .aac-sched-edit-grid-headers > *:nth-child(3),
  .aac-sched-edit-grid-headers > *:nth-child(4),
  .aac-sched-edit-row > *:nth-child(3),
  .aac-sched-edit-row > *:nth-child(4) {
    grid-column: span 1;
  }
  .aac-sched-header { padding: 16px 20px 12px; }
  .aac-sched-phases { padding: 8px 20px 12px; }
  .aac-sched-warnings { margin: 0 20px 12px; }
  .aac-sched-footer { padding: 14px 20px; }
}
