/* Custom CSS for Annual Leave Planner */

:root {
  --app-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --weekend-bg: #f1f5f9;
  --bank-holiday-bg: #e0f2fe;
  --bank-holiday-border: #0284c7;
  --today-border: #ef4444;
}

body {
  /* background-color: var(--app-bg); */
  min-height: 100vh;
}

/* Slim application header */
.app-header {
  /* background-color: var(--card-bg); */
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  padding-top: 0;
  padding-bottom: 0;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.5rem;
}

.app-header-brand {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--pico-h1-color, #1e293b);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-brand:hover {
  text-decoration: underline;
}

.app-header-user {
  position: relative;
  flex-shrink: 0;
}

.app-header-user-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  margin-bottom: 0;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  line-height: 1.2;
  color: inherit;
  background-color: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
}

.app-header-user-button:hover,
.app-header-user-button[aria-expanded="true"] {
  background-color: var(--weekend-bg);
}

.app-header-user-name {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header-user-caret {
  font-size: 0.7rem;
  opacity: 0.7;
}

.app-header-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 100;
  min-width: 12rem;
  padding: 0.25rem;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.app-header-menu[hidden] {
  display: none;
}

.app-header-menu-form {
  margin-bottom: 0;
}

.app-header-menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  line-height: 1.2;
  text-align: left;
  color: inherit;
  text-decoration: none;
  background-color: transparent;
  border: none;
  border-radius: 5px;
  margin-bottom: 0;
  cursor: pointer;
}

.app-header-menu-item:hover {
  background-color: var(--weekend-bg);
  text-decoration: none;
}

.app-header-menu-item-danger {
  color: #b91c1c;
}

.site-nav {
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 0;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.site-nav .container,
.site-nav .container-fluid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--pico-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.75rem;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--pico-muted-color);
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--pico-primary, #0284c7);
  background-color: #f0f9ff;
}

.flash-message {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1.25rem;
  border-radius: 6px;
  background-color: #ecfdf5;
  border: 1px solid #10b981;
  color: #065f46;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Calendar Main Layout: Calendar area on left, Allowances sidebar on right */
.calendar-layout-container {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.calendar-main-col {
  flex: 1 1 0%;
  min-width: 0;
}

.calendar-sidebar-col {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
}

@media (max-width: 1100px) {
  .calendar-layout-container {
    flex-direction: column;
  }

  .calendar-sidebar-col {
    width: 100%;
    position: static;
  }
}

.person-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.person-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.leave-year-summary {
  border-top: 1px solid var(--border-color);
  margin-top: 0.65rem;
  padding-top: 0.65rem;
}

.leave-year-summary-title {
  color: var(--pico-color);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0;
  padding-right: 1.5rem;
  position: relative;
}

.leave-year-summary-title::after {
  float: none;
  position: absolute;
  right: 0;
  top: 0.15rem;
}

.leave-year-summary[open] .leave-year-summary-title {
  margin-bottom: 0.4rem;
}

.leave-year-summary-title small {
  color: var(--pico-muted-color);
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
}

.person-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-top: 0.3rem;
  color: var(--pico-muted-color);
}

.stats-value {
  font-weight: 600;
  color: var(--pico-color);
  text-align: right;
}

/* Calendar Controls Header */
.calendar-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  /* background: var(--card-bg); */
  /* border: 1px solid var(--border-color); */
  border-radius: 8px;
  /* padding: 0.75rem 1.25rem; */
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: relative;
}

.calendar-year-navigation {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-left: auto;
  margin-right: auto;
}

.calendar-year-title {
  min-width: 5rem;
  color: var(--pico-color);
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
}

.calendar-year-arrow {
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.65rem;
}

.calendar-layout-toggle {
  display: inline-flex;
  flex: 0 1 120px;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 6px;
  margin-bottom: 0;
}

.calendar-layout-toggle-form {
  margin: 0;
}

.calendar-layout-toggle-button {
  margin: 0;
  padding: 0.35rem 0.75rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--pico-muted-color);
  font-size: 0.875rem;
}

.calendar-layout-toggle-form
  + .calendar-layout-toggle-form
  .calendar-layout-toggle-button {
  border-left: 1px solid var(--pico-muted-border-color);
}

.calendar-layout-toggle-button.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.nav-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 6px;
  margin-bottom: 0;
  text-decoration: none;
  white-space: nowrap;
}

/* Calendar Multi-Month Grid: fixed 4-column desktop / 3-column / 2-column / 1-column */
.calendar-grid-12 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.2rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1600px) {
  .calendar-grid-12 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1250px) {
  .calendar-grid-12 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .calendar-grid-12 {
    grid-template-columns: 1fr;
  }
}

.month-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.4rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-sizing: border-box;
}

.month-card.current-month {
  border: 2px solid var(--bank-holiday-border);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.month-card.past-month {
  opacity: 0.5;
}

.month-header {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--pico-color);
}

@media (max-width: 700px) {
  .calendar-controls {
    justify-content: space-between;
  }

  .calendar-controls > [role="button"] {
    position: static;
  }
}

.days-of-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--pico-muted-color);
  margin-bottom: 0.25rem;
}

.month-days-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.day-cell {
  height: 40px;
  /* border: 1px solid #f1f5f9; */
  /* border-radius: 4px; */
  padding: 2px;
  font-size: 0.75rem;
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background-color: #ffffff;
  transition: all 0.1s ease-in-out;
  text-decoration: none;
  color: inherit;
  user-select: none;
  overflow: hidden;
  box-sizing: border-box;
}

.day-cell:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.day-cell.empty {
  background-color: transparent;
  border-color: transparent;
  cursor: default;
}

.day-cell.weekend {
  background-color: var(--weekend-bg);
}

.day-cell.today {
  border: 2px solid var(--today-border);
  font-weight: 700;
}

.day-cell.bank-holiday {
  background-color: var(--bank-holiday-bg);
  border-color: var(--bank-holiday-border);
}

/* Colour bands come from each calendar's own colour, set inline per day. */
.day-cell.additional-calendar-day {
  padding-bottom: 4px;
}

.day-number {
  /* font-weight: 600; */
  font-size: 0.6rem;
  line-height: 1;
  margin-bottom: 2px;
}

.day-badges {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1px;
  overflow: hidden;
  flex: 1;
}

.leave-badge {
  font-size: 0.62rem;
  padding: 1px 3px;
  border-radius: 3px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
  font-weight: 500;
}

.bh-badge {
  font-size: 0.58rem;
  color: #0369a1;
  background-color: #bae6fd;
  border-radius: 2px;
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
  display: block;
}

.sh-badge {
  font-size: 0.58rem;
  color: #92400e;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Calendar List Layout: each month as one horizontal row of days, stacked vertically */
.calendar-list-12 {
  display: grid;
  grid-template-rows: repeat(12, minmax(0, 1fr));
  grid-template-columns: 1.2rem repeat(31, minmax(0, 1fr));
  grid-row-gap: 0.5rem;
  grid-column-gap: 0;
  margin-bottom: 1.5rem;
}

.month-list-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: stretch;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
  height: 52px;
}

.month-list-row.current-month {
  border: 1px solid var(--bank-holiday-border);
  outline: 2px solid var(--bank-holiday-border);
  /* box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15); */
}

.month-list-row.past-month {
  opacity: 0.5;
}

.month-list-label {
  writing-mode: sideways-lr;
  text-orientation: mixed;
  text-transform: uppercase;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pico-color);
  border-right: 1px solid var(--border-color);
}

.month-list-days {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.day-cell-list {
  position: relative;
  overflow: visible;
  height: 50px;
  padding: 0px;
  border-right: 1px solid var(--border-color);
}

.day-cell-list:nth-child(32) {
  border-right: none;
}

.day-cell-list.today {
  border: none;
}

.day-cell-list .day-number {
  position: absolute;
  width: 22px;
  height: 22px;
  top: -3px;
  left: -3px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
  /* font-weight: 700; */
}

.day-cell-list.today .day-number {
  background-color: var(--today-border);
  color: #ffffff;
  border-radius: 50%;
}

.day-weekday {
  font-size: 0.55rem;
  line-height: 1;
  color: var(--pico-muted-color);
  text-align: center;
}

.day-cell-list .day-number {
  margin-bottom: 2px;
}

.day-cell-list .day-badges {
  margin-top: 16px;
  flex-direction: column;
  gap: 2px;
}

.day-cell-list .leave-badge {
  display: block;
  width: 100%;
  text-align: center;
  border-radius: 0;
  font-size: 0.5rem;
}

.day-cell-list .leave-badge--start {
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
}

.day-cell-list .leave-badge--end {
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
}

@media (max-width: 900px) {
  .month-list-row {
    flex-direction: column;
    gap: 0.35rem;
  }

  .month-list-label {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 0.35rem;
    justify-content: flex-start;
  }
}

/* Legend */
.legend-bar {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  display: inline-block;
  flex-shrink: 0;
}

/* Modal and dialog */
dialog article {
  max-width: 550px;
}
