/* ----------------------------------------------------------
   Weekend Duty Roster
---------------------------------------------------------- */

.eac-weekend-duty-form {
    margin-top: 12px;
}

.eac-weekend-duty-table-container {
    margin-top: 8px;
    background-color: #020617;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #111827;
    overflow-x: auto;
    position: relative;
    /* Create a dedicated stacking context so sticky layers composite cleanly */
    isolation: isolate;
}

/*
  NOTE:
  Some browsers can show a 1–2px “peek” of the scrolled columns at the far-left
  edge due to subpixel rounding while sticky cells are composited.
  The most reliable fix is to extend the first sticky column's background
  slightly past the left edge via a pseudo-element (see below).
*/

.eac-weekend-duty-table {
    width: 100%;
    /*
      Sticky columns + border-collapse: collapse can cause background “bleed”
      while horizontally scrolling (you see slivers of underlying columns).
      Use separate/0 spacing so sticky cells stay visually solid.
    */
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8rem;
    min-width: 640px;

    /* Sticky column offsets (set via JS for accuracy). */
    --eac-wd-col1-w: 220px;

    /* Sticky surface color (defaults to table container background). */
    --eac-wd-sticky-bg: #ffffff;
}

.eac-weekend-duty-table th,
.eac-weekend-duty-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #1f2937;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.eac-weekend-duty-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    color: #e5e7eb;
    background-color: #020617;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ------------------------------------------------------------------
   Weekend Duty: Sticky first two columns (Member + Weekend Duties)
   - Keeps identity + count visible while scrolling horizontally.
------------------------------------------------------------------ */

/* First column: Member */

.eac-weekend-duty-table th.eac-weekend-duty-name-col,
.eac-weekend-duty-table td.eac-weekend-duty-name {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 3;
    background-color: var(--eac-wd-sticky-bg);
    background-clip: padding-box;
    /* Needed for ::before and to ensure the sticky bg fully covers */
    overflow: visible;
    /* Divider + hide any 1px seam */
    box-shadow: -1px 0 0 rgba(0,0,0,0.12);
    will-change: transform;
}

/* Extend sticky background past the left edge to hide subpixel “peek” */
.eac-weekend-duty-table th.eac-weekend-duty-name-col::before,
.eac-weekend-duty-table td.eac-weekend-duty-name::before {
    content: "";
    position: absolute;
    top: 0;
    left: -28px;
    width: 28px;
    height: 100%;
    background: var(--eac-wd-sticky-bg);
    pointer-events: none;
    /* Above the scrolled columns; stays outside the text area */
    z-index: 10;
}

/* Second column: Weekend Duties */
.eac-weekend-duty-table th.eac-weekend-duty-count-col,
.eac-weekend-duty-table td.eac-weekend-duty-count {
    position: sticky;
    left: var(--eac-wd-col1-w);
    z-index: 2;
    background-color: var(--eac-wd-sticky-bg);
    background-clip: padding-box;

    /* Visual divider to hide any edge artifacts and clarify the “pinned” area */
    box-shadow: 1px 0 0 #1f2937;
}

/* Ensure the sticky header cells stay above the body cells */
.eac-weekend-duty-table thead th.eac-weekend-duty-name-col,
.eac-weekend-duty-table thead th.eac-weekend-duty-count-col {
    z-index: 5;
}

/* Body row layering */
.eac-weekend-duty-table tbody td.eac-weekend-duty-name {
    z-index: 4;
}

.eac-weekend-duty-table tbody td.eac-weekend-duty-count {
    z-index: 3;
}

/* Header: per-week totals + override */
.eac-wd-weekhead {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.eac-wd-weeklabel {
    line-height: 1.15;
}

.eac-wd-weekmeta {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font-size: 0.7rem;
    color: #9ca3af;
}

.eac-wd-override-toggle {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.10);
    color: #bfdbfe;
    font-size: 0.7rem;
    cursor: pointer;
    user-select: none;
}

.eac-wd-override-toggle input {
    display: none;
}

.eac-wd-override-toggle input:checked + .eac-wd-override-label {
    color: #ffffff;
}

.eac-wd-override-toggle:has(input:checked) {
    border-color: rgba(59, 130, 246, 0.65);
    background: rgba(59, 130, 246, 0.22);
}

.eac-wd-override-toggle.is-hidden {
    display: none;
}

/* Per-week state indicators (only used when exact target is enabled) */
.eac-weekend-duty-table thead th.eac-wd-week-under {
    box-shadow: inset 0 -2px 0 rgba(239, 68, 68, 0.60);
}

.eac-weekend-duty-table thead th.eac-wd-week-over {
    box-shadow: inset 0 -2px 0 rgba(245, 158, 11, 0.65);
}

.eac-weekend-duty-table thead th.eac-wd-week-exact {
    box-shadow: inset 0 -2px 0 rgba(34, 197, 94, 0.60);
}

.eac-weekend-duty-name-col,
.eac-weekend-duty-name {
    text-align: left;
    white-space: nowrap;
}

.eac-weekend-duty-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.eac-weekend-duty-actions {
    margin-top: 12px;
    text-align: right;
}

.eac-helper-text {
    font-size: 0.8rem;
    color: #9ca3af;
    margin: 8px 0;
}

.eac-notice {
    margin-top: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
}

.eac-notice-success {
    background-color: #052e16;
    border: 1px solid #16a34a;
    color: #bbf7d0;
}

.eac-notice-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.eac-weekend-duty-count-col,
.eac-weekend-duty-count {
    text-align: center;
    font-weight: 600;
}

.eac-weekend-duty-summary-row {
    background-color: #020617;
}

.eac-weekend-duty-summary-row td {
    font-weight: 600;
}

/* Weekend Duty - Light theme overrides */

.eac-wrapper.eac-theme-light .eac-weekend-duty-table-container {
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

.eac-wrapper.eac-theme-light .eac-weekend-duty-table-container::before {
    background-color: #f9fafb;
}

.eac-wrapper.eac-theme-light .eac-weekend-duty-table thead th {
    background-color: #e5e7eb;
    color: #111827;
}

/* Sticky columns: match light theme surfaces */
.eac-wrapper.eac-theme-light .eac-weekend-duty-table th.eac-weekend-duty-name-col,
.eac-wrapper.eac-theme-light .eac-weekend-duty-table td.eac-weekend-duty-name,
.eac-wrapper.eac-theme-light .eac-weekend-duty-table th.eac-weekend-duty-count-col,
.eac-wrapper.eac-theme-light .eac-weekend-duty-table td.eac-weekend-duty-count {
    background-color: #f9fafb;
    background-clip: padding-box;
}

.eac-wrapper.eac-theme-light .eac-weekend-duty-table th.eac-weekend-duty-count-col,
.eac-wrapper.eac-theme-light .eac-weekend-duty-table td.eac-weekend-duty-count {
    box-shadow: 1px 0 0 #e5e7eb;
}

.eac-wrapper.eac-theme-light .eac-weekend-duty-table th.eac-weekend-duty-name-col,
.eac-wrapper.eac-theme-light .eac-weekend-duty-table td.eac-weekend-duty-name {
    box-shadow: -1px 0 0 #e5e7eb;
}

.eac-wrapper.eac-theme-light .eac-weekend-duty-table th,
.eac-wrapper.eac-theme-light .eac-weekend-duty-table td {
    border-bottom-color: #e5e7eb;
}

.eac-wrapper.eac-theme-light .eac-weekend-duty-summary-row {
    background-color: #e5f0ff;
}


/* ------------------------------------------------------------------
   Weekend Duty: Auto-populate controls (header)
------------------------------------------------------------------ */

.eac-wd-auto-controls {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-right: 12px;
}

.eac-wd-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.eac-wd-toggle-text {
    font-size: 13px;
    font-weight: 700;
}

.eac-wd-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
}

.eac-wd-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.eac-wd-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    border-radius: 999px;
    background-color: #9ca3af;
    transition: background-color 0.2s ease;
}

.eac-wd-slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    background-color: #ffffff;
    transition: transform 0.2s ease;
}

.eac-wd-switch input:checked + .eac-wd-slider {
    background-color: #16a34a;
}

.eac-wd-switch input:checked + .eac-wd-slider:before {
    transform: translateX(20px);
}

.eac-wd-populate-btn {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.75);
    background: transparent;
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
}

.eac-wd-populate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.eac-wd-auto-message {
    font-size: 12px;
    font-weight: 700;
    min-width: 150px;
}

/* Theme-aware text/button colors */
.eac-wrapper.eac-theme-dark .eac-wd-toggle-text,
.eac-wrapper.eac-theme-dark .eac-wd-auto-message,
.eac-wrapper.eac-theme-dark .eac-wd-populate-btn {
    color: #e5e7eb;
}

.eac-wrapper.eac-theme-light .eac-wd-toggle-text,
.eac-wrapper.eac-theme-light .eac-wd-auto-message,
.eac-wrapper.eac-theme-light .eac-wd-populate-btn {
    color: #111827;
}

/* ------------------------------------------------------------------
   Weekend Duty: header sub-row (Clear All + Group ID + Populate Now)
------------------------------------------------------------------ */

/* Override the shared .eac-header layout for Weekend Duty only */
.eac-header.eac-wd-header {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
}

.eac-wd-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.eac-wd-header-sub {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.eac-wd-header-sub-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.eac-wd-header-sub-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.eac-wd-sub-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.eac-wd-clear-btn {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.75);
    background: transparent;
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
}

.eac-wd-clear-btn:hover {
    border-color: rgba(239, 68, 68, 0.85);
}

/* Theme-aware text/button colors */
.eac-wrapper.eac-theme-dark .eac-wd-clear-btn {
    color: #e5e7eb;
}

.eac-wrapper.eac-theme-light .eac-wd-clear-btn {
    color: #111827;
}

