/* Orar atelier — se încarcă după css/style.css și teams/teams.css; folosește doar tokenii site-ului. */

#orar-app {
  display: grid;
  gap: 24px;
  min-width: 0;
  overflow-wrap: anywhere;   /* note și nume lungi nu ies din ecran la 360px (1.4.10) */
}

#orar-app > *,
.orar-day,
.orar-decide-actions {
  min-width: 0;
}

#orar-app :is(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--color-yellow);
  outline-offset: 2px;
}

:root[data-theme="light"] #orar-app :is(button, a, input, select, [tabindex]):focus-visible {
  outline-color: #b45309;
}

#orar-app :is(h2, h3)[tabindex="-1"]:focus:not(:focus-visible) {
  outline: none;
}

#orar-app :is(h2, h3, button, input, select, [tabindex]) {
  scroll-margin-top: calc(var(--header-height, 80px) + 16px);
}

/* ---------------------------------------------------------------- acum */
.orar-now {
  padding: 24px 28px;
  border-left: 4px solid var(--border-color);
}

.orar-now--open {
  border-left-color: var(--color-laurel);
}

.orar-now-state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px;
  font-family: var(--font-logo);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  color: var(--text-primary);
}

.orar-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
}

.orar-now--open .orar-dot {
  background: var(--color-laurel);
  box-shadow: 0 0 0 4px rgba(111, 188, 66, 0.25);
}

.orar-now-detail {
  margin: 0 0 4px;
  font-size: 1.0625rem;
  color: var(--text-primary);
}

.orar-now-time {
  margin: 0;
  font-size: 0.75rem;
}

.orar-now-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* badge-uri: text + chenar, nu doar culoare */
.orar-badge--present,
.orar-badge--accepted {
  border-color: var(--color-laurel);
  color: var(--text-primary);
  background: rgba(111, 188, 66, 0.16);
}

.orar-badge--confirmed {
  border-color: var(--color-laurel);
  color: var(--text-primary);
}

.orar-badge--override,
.orar-badge--pending {
  border-style: dashed;
}

.orar-badge--rejected,
.orar-badge--cancelled {
  color: var(--text-secondary);
  text-decoration: line-through;
}

.orar-badge--today {
  background: var(--color-yellow);
  color: #1a1a1a;
  border-color: var(--color-yellow);
}

.orar-badge--override {
  white-space: normal;   /* nota poate fi lungă */
}

/* Rândurile .tm-banner (--bg-highlight): textul secundar și insignele chihlimbar trebuie să atingă 4.5:1 */
#orar-app .tm-banner .text-muted {
  color: var(--text-secondary);
}

:root[data-theme="light"] #orar-app .tm-banner .tm-badge {
  color: #92400e;
}

/* teams.css forțează #b45309 pe toate insignele în tema deschisă (specificitate 1,3,0);
   variantele de mai jos au specificitate mai mare, în ambele teme */
:root[data-theme] #orar-app .tm-badge.orar-badge.orar-badge--present,
:root[data-theme] #orar-app .tm-badge.orar-badge.orar-badge--accepted,
:root[data-theme] #orar-app .tm-badge.orar-badge.orar-badge--confirmed {
  color: var(--text-primary);
}

:root[data-theme] #orar-app .tm-badge.orar-badge.orar-badge--rejected,
:root[data-theme] #orar-app .tm-badge.orar-badge.orar-badge--cancelled {
  color: var(--text-secondary);
}

:root[data-theme] #orar-app .tm-badge.orar-badge.orar-badge--today {
  border-color: var(--color-yellow);
  background: var(--color-yellow);
  color: #262220;
}

/* ---------------------------------------------------------------- cereri */
.orar-requests {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}

.orar-requests h4 {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.orar-requests ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.orar-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.orar-my-requests {
  margin-top: 20px;
}

.orar-admin {
  display: grid;
  gap: 16px;
}

.orar-admin > h2 {
  margin: 8px 0 0;
}

.orar-decide {
  display: grid;
  gap: 10px;
}

.orar-decide-actions {
  display: grid;
  gap: 10px;
}

@media (max-width: 560px) {
  .orar-now {
    padding: 18px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;   /* style.css pune smooth; orar.css se încarcă doar pe pagina asta */
  }
  #orar-app * {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .orar-dot,
  .orar-now-line,
  .orar-swatch {
    background: Highlight;
    forced-color-adjust: none;
  }
}

/* ================================================================
   Calendar săptămânal (în stilul Google Calendar) + legendă
   ================================================================ */
.orar-cal-wrap {
  display: grid;
  gap: 16px;
}

.orar-cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.orar-cal-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.orar-cal-title h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

/* „Sari peste calendar”: ascunsă vizual până primește focus */
.orar-skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.orar-skip:focus {
  justify-self: start;
  padding: 10px 16px;
  background: var(--color-yellow);
  color: #1a1a1a;
  font-weight: 700;
  text-decoration: underline;
}

#orar-app .orar-skip:focus-visible {
  outline-color: var(--text-primary);
}

.orar-cal-wrap {
  position: relative;
}

/* ținta legăturii: la capătul calendarului, fără să ocupe un rând în grilă */
#orar-cal-end {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
}

.orar-cal-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ---------------------------------------------------------------- legendă */
.orar-legend {
  position: sticky;
  top: calc(var(--header-height, 80px) + 16px);
  padding: 18px 16px;
}

.orar-legend h3 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.orar-legend-sub {
  margin-top: 18px !important;
}

.orar-legend-list,
.orar-legend-keys {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.orar-legend-list li {
  position: relative;
}

/* bifa reală rămâne focusabilă; o ascundem vizual și desenăm pătratul colorat */
.orar-legend-check {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.orar-legend-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 6px 6px;
  cursor: pointer;
}

.orar-legend-list label:hover {
  background: var(--bg-highlight);
}

.orar-swatch {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 2px solid var(--c);
  background: var(--c);
  position: relative;
  box-shadow: 0 0 0 1px var(--text-secondary);   /* contur ≥ 3:1 indiferent de culoare (1.4.11) */
}

/* bifat = pătrat plin cu ✓; debifat = doar contur (diferență de formă, nu doar de culoare) */
.orar-swatch::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.orar-legend-check:not(:checked) + label .orar-swatch {
  background: transparent;
}

.orar-legend-check:not(:checked) + label .orar-swatch::after {
  display: none;
}

/* fără opacity: textul debifat rămâne ≥ 4.5:1 (1.4.3) */
.orar-legend-check:not(:checked) + label .orar-legend-text {
  color: var(--text-secondary);
  text-decoration: line-through;
}

.orar-legend-check:focus-visible + label {
  outline: 2px solid var(--color-yellow);
  outline-offset: 2px;
}

:root[data-theme="light"] .orar-legend-check:focus-visible + label {
  outline-color: #b45309;
}

.orar-legend-text {
  display: grid;
  min-width: 0;
}

.orar-legend-name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.3;
}

.orar-legend-title {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.orar-legend-keys li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  font-size: 0.8125rem;
}

.orar-key {
  flex: none;
  width: 18px;
  height: 12px;
}

.orar-key--open {
  background: rgba(252, 179, 28, 0.18);
  border-left: 3px solid var(--color-yellow);
}

.orar-key--request {
  border: 2px dashed var(--text-secondary);
}

.orar-key--now {
  height: 2px;
  background: #e11d48;
}

.orar-key-text {
  width: 18px;
  text-align: center;
  font-weight: 700;
}

.orar-legend-note {
  margin: 12px 0 0;
  font-size: 0.75rem;
}

/* ---------------------------------------------------------------- grila */
.orar-cal-main {
  min-width: 0;
}

.orar-cal {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

.orar-cal-head,
.orar-cal-body {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(0, 1fr));
}

.orar-cal-head {
  position: sticky;
  top: var(--header-height, 80px);
  z-index: 5;   /* peste evenimentele extinse (4) */
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.orar-head-cell {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-left: 1px solid var(--border-color);
  text-align: center;
}

.orar-head-day {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.orar-head-num {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-family: var(--font-logo);
  font-size: 1.35rem;
  font-weight: 700;
  border-radius: 50%;
}

.orar-head-cell.is-today .orar-head-num {
  background: var(--color-yellow);
  color: #1a1a1a;
}

.orar-head-open {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.orar-gutter {
  position: relative;
}

.orar-gutter-hour {
  height: 48px;
  padding-right: 8px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-secondary);
  transform: translateY(-0.6em);
}

.orar-gutter-hour:first-child {
  transform: none;
}

.orar-col {
  position: relative;
  border-left: 1px solid var(--border-color);
  min-width: 0;
}

.orar-col.is-today {
  background: rgba(252, 179, 28, 0.04);
}

.orar-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border-color);
  opacity: 0.6;
}

.orar-open-band {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(252, 179, 28, 0.10);
  border-left: 3px solid var(--color-yellow);
}

:root[data-theme="light"] .orar-open-band {
  background: rgba(180, 83, 9, 0.08);
  border-left-color: #b45309;
}

.orar-events {
  margin: 0;
  padding: 0;
  list-style: none;
}

.orar-event {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  padding: 3px 6px;
  border-left: 4px solid var(--c);
  background: color-mix(in srgb, var(--c) 22%, var(--bg-card));
  color: var(--text-primary);
  font-size: 0.75rem;
  line-height: 1.25;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* extins: la hover ȘI la focus de la tastatură (2.1.1, 1.4.13); Escape adaugă .is-dismissed (orar.js).
   z-index peste vecini și peste linia orei curente (2), sub antetul lipicios (5) */
.orar-event:is(:hover, :focus-visible, :focus-within):not(.is-dismissed) {
  z-index: 4;
  overflow: visible;
  height: auto !important;
  min-height: fit-content;
  background: color-mix(in srgb, var(--c) 32%, var(--bg-card));
}

/* focusul nu ajunge sub antetul site-ului + antetul lipicios al calendarului (2.4.11) */
#orar-app .orar-event {
  scroll-margin-top: calc(var(--header-height, 80px) + 110px);
}

#orar-app .orar-event:focus-visible {
  outline-offset: 1px;
}

.orar-event-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.orar-event-time {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.orar-event-title,
.orar-event-flags {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* chenar interior prin box-shadow, ca outline-ul să rămână liber pentru indicatorul de focus */
.orar-event.is-present {
  box-shadow: inset 0 0 0 2px var(--color-laurel), 0 1px 2px rgba(0, 0, 0, 0.2);
}

.orar-event.is-override {
  border-left-style: dashed;
}

.orar-event--request {
  --c: var(--text-secondary);
  background: var(--bg-card);
  border: 2px dashed var(--text-secondary);
  border-left-width: 2px;
}

/* extinsă, cererea rămâne pe fundalul cardului: amestecul cu --text-secondary ar coborî textul secundar sub 4.5:1 în tema închisă */
.orar-event--request:is(:hover, :focus-visible, :focus-within):not(.is-dismissed) {
  background: var(--bg-card);
}

.orar-event--request.is-pending {
  opacity: 0.85;
}

.orar-event--absent {
  background: transparent;
  border: 1px dashed var(--c);
  border-left-width: 4px;
  border-left-style: solid;
}

.orar-now-line {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  height: 2px;
  background: #e11d48;
  pointer-events: none;
}

.orar-now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e11d48;
}

.orar-badge--parity {
  font-family: var(--font-mono);
}

/* bloc îngust: doar inițiale vizibile; textul complet rămâne accesibil (ascuns vizual, nu display:none) */
.orar-event.is-narrow {
  align-items: center;
  padding: 3px 0;
  border-left-width: 0;
  border-top: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 30%, var(--bg-card));
}

.orar-event.is-narrow > :not(.orar-event-initials) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.orar-event-initials {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  writing-mode: vertical-rl;
  text-orientation: upright;
}

/* îngust + extins (hover/focus): textul complet, lățime minimă lizibilă */
.orar-event.is-narrow:is(:hover, :focus-visible, :focus-within):not(.is-dismissed) {
  align-items: stretch;
  left: 2px !important;
  width: auto !important;
  min-width: min(10rem, calc(100vw - 32px));
  padding: 3px 6px;
  border-top-width: 0;
  border-left-width: 4px;
}

/* ultima coloană: ancorat la dreapta, ca să nu iasă din calendar */
.orar-col:last-of-type .orar-event.is-narrow:is(:hover, :focus-visible, :focus-within):not(.is-dismissed) {
  left: auto !important;
  right: 2px;
}

.orar-event.is-narrow:is(:hover, :focus-visible, :focus-within):not(.is-dismissed) > :not(.orar-event-initials, .tm-sr-only) {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.orar-event.is-narrow:is(:hover, :focus-visible, :focus-within):not(.is-dismissed) > .orar-event-initials {
  display: none;
}

/* ---------------------------------------------------------------- alegere zi (mobil) */
.orar-day-chips {
  display: none;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 10px;
}

#orar-app .orar-chip {
  display: grid;
  justify-items: center;
  gap: 0;
  min-height: 52px;
  padding: 4px 0;
}

.orar-chip-day {
  font-size: 0.625rem;
  letter-spacing: 0.06em;
}

.orar-chip-num {
  font-family: var(--font-logo);
  font-size: 1.15rem;
}

#orar-app .orar-chip[aria-pressed="true"] {
  background: var(--color-yellow);
  border-color: var(--color-yellow);
  color: #1a1a1a;
}

#orar-app .orar-chip--today .orar-chip-num {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* închis: chenar punctat, textul rămâne la contrast plin (numele butonului spune „închis”) */
#orar-app .orar-chip--closed {
  border-style: dashed;
}

/* ---------------------------------------------------------------- program săptămânal (admin) */
.orar-weekly-table {
  width: 100%;
  border-collapse: collapse;
}

.orar-weekly-table th,
.orar-weekly-table td {
  padding: 6px 6px 6px 0;
  text-align: left;
  vertical-align: top;
}

.orar-weekly-table thead th {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.orar-weekly-table tbody th {
  padding-top: 16px;
  white-space: nowrap;
}

.orar-weekly-cell {
  display: grid;
  gap: 4px;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .orar-cal-layout {
    grid-template-columns: 1fr;
  }
  .orar-legend {
    position: static;
    order: 2;   /* pe ecrane mai mici legenda vine după calendar */
  }
  .orar-legend-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .orar-day-chips {
    display: grid;
  }
  .orar-cal-head,
  .orar-cal-body {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .orar-head-cell:not(.is-picked),
  .orar-col:not(.is-picked) {
    display: none;
  }
  .orar-cal-head {
    position: static;
  }
  #orar-app .orar-event {
    scroll-margin-top: calc(var(--header-height, 80px) + 16px);   /* antetul calendarului nu mai e lipicios */
  }
  .orar-nav-text {
    font-size: 0.75rem;
  }
  .orar-weekly-table thead {
    display: none;
  }
  .orar-weekly-table,
  .orar-weekly-table tbody,
  .orar-weekly-table tr,
  .orar-weekly-table th,
  .orar-weekly-table td {
    display: block;
    width: 100%;
  }
  .orar-weekly-table tr {
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
  }
  .orar-weekly-table td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
  }
}

/* Contrast ridicat (Windows): culorile coordonatorilor dispar, deci fiecare eveniment primește chenar vizibil;
   la final ca să bată regulile de bază ale evenimentelor (aceeași specificitate, ordinea contează) */
@media (forced-colors: active) {
  #orar-app .orar-event {
    border: 1px solid CanvasText;
    border-left-width: 4px;
  }
  #orar-app .orar-event--request,
  #orar-app .orar-event--absent {
    border-style: dashed;
  }
  #orar-app .orar-event.is-override {
    border-left-style: dashed;
  }
  #orar-app .orar-event.is-narrow:not(:hover, :focus-visible, :focus-within) {
    border-left-width: 1px;
    border-top-width: 3px;
  }
  .orar-swatch {
    border-color: CanvasText;
  }
  .orar-swatch::after {
    border-color: HighlightText;   /* bifa rămâne vizibilă pe Highlight */
  }
}
