/* ==========================================================================
   Recurring Schedule - Modern Compact Layout
   ========================================================================== */

/* Container wrapper */
.wsscd-recurring-schedule {
    position: relative;
}

/* Schedule Type Selection Cards */
.wsscd-schedule-type-selection {
    margin-bottom: var(--wsscd-spacing-xl);
}

.wsscd-schedule-type-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--wsscd-gap-comfortable);
}

.wsscd-schedule-type-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--wsscd-spacing-md);
    padding: var(--wsscd-padding-section);
    background: var(--wsscd-color-white);
    border: var(--wsscd-border-width) solid var(--wsscd-color-border);
    border-radius: var(--wsscd-radius-md);
    cursor: pointer;
    transition: border-color var(--wsscd-transition-fast) ease,
                box-shadow var(--wsscd-transition-fast) ease,
                background var(--wsscd-transition-fast) ease;
    overflow: hidden;
}

.wsscd-schedule-type-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background var(--wsscd-transition-fast) ease;
}

.wsscd-schedule-type-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wsscd-schedule-type-card:hover {
    border-color: var(--wsscd-color-border-dark);
}

.wsscd-schedule-type-card:hover::before {
    background: var(--wsscd-color-primary);
}

.wsscd-schedule-type-card.selected,
.wsscd-schedule-type-card:has(input[type="radio"]:checked) {
    border-color: var(--wsscd-color-primary);
    border-width: var(--wsscd-border-width-thick);
    background: var(--wsscd-color-primary-bg);
}

.wsscd-schedule-type-card.selected::before,
.wsscd-schedule-type-card:has(input[type="radio"]:checked)::before {
    background: var(--wsscd-color-primary);
}

.wsscd-schedule-type-card__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--wsscd-color-primary-alpha-10);
    border-radius: var(--wsscd-radius-md);
    transition: background var(--wsscd-transition-fast) ease,
                transform var(--wsscd-transition-fast) ease;
}

.wsscd-schedule-type-card__icon .wsscd-icon {
    color: var(--wsscd-color-primary);
    transition: color var(--wsscd-transition-fast) ease;
}

.wsscd-schedule-type-card:hover .wsscd-schedule-type-card__icon {
    transform: scale(1.05);
}

.wsscd-schedule-type-card.selected .wsscd-schedule-type-card__icon,
.wsscd-schedule-type-card:has(input[type="radio"]:checked) .wsscd-schedule-type-card__icon {
    background: var(--wsscd-color-primary-alpha-20);
}

.wsscd-schedule-type-card__content h5 {
    margin: 0 0 var(--wsscd-spacing-xxs) 0;
    font-size: var(--wsscd-font-size-medium);
    font-weight: var(--wsscd-font-weight-semibold);
    color: var(--wsscd-color-text);
}

.wsscd-schedule-type-card__content p {
    margin: 0;
    font-size: var(--wsscd-font-size-small);
    color: var(--wsscd-color-text-muted);
    line-height: 1.4;
}

/* Recurring Configuration Container */
.wsscd-recurring-config {
    animation: wsscd-slide-in-down var(--wsscd-transition-base) ease;
}

@keyframes wsscd-slide-in-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Disabled day chips */
.wsscd-day-chip.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--wsscd-color-surface-light, #f0f0f0);
    border-color: var(--wsscd-color-border-light, #ddd);
}

.wsscd-day-chip.disabled input[type="checkbox"] {
    cursor: not-allowed;
}

.wsscd-day-chip.disabled:hover {
    border-color: var(--wsscd-color-border-light, #ddd);
    transform: none;
}

/* Interval validation warning */
/* Recurrence end date warning */

/* Monthly edge case info (informational, not warning) */

/* Day Chips - Compact Single Letter */
.wsscd-day-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--wsscd-color-white);
    border: 2px solid var(--wsscd-color-border);
    border-radius: var(--wsscd-radius-full);
    cursor: pointer;
    transition: all var(--wsscd-transition-fast) ease;
    font-size: var(--wsscd-font-size-small);
    font-weight: var(--wsscd-font-weight-semibold);
    color: var(--wsscd-color-text);
    user-select: none;
}

.wsscd-day-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wsscd-day-chip:hover {
    border-color: var(--wsscd-color-primary);
    background: var(--wsscd-color-primary-alpha-10);
}

.wsscd-day-chip.selected,
.wsscd-day-chip:has(input[type="checkbox"]:checked) {
    background: var(--wsscd-color-primary);
    border-color: var(--wsscd-color-primary);
    color: var(--wsscd-color-white);
}

.wsscd-day-chip:focus-within {
    outline: 2px solid var(--wsscd-color-primary);
    outline-offset: 2px;
}

/* Schedule Summary Section */
.wsscd-schedule-summary {
    background: var(--wsscd-color-white);
    border: 2px solid var(--wsscd-color-border-light);
    border-radius: var(--wsscd-radius-lg);
    overflow: hidden;
    margin-bottom: var(--wsscd-spacing-xl);
    box-shadow: var(--wsscd-shadow-sm);
}

.wsscd-schedule-summary__text {
    display: flex;
    align-items: center;
    gap: var(--wsscd-spacing-sm);
    padding: var(--wsscd-spacing-lg);
    background: linear-gradient(135deg, var(--wsscd-color-primary-alpha-10) 0%, var(--wsscd-color-surface) 100%);
    border-bottom: var(--wsscd-border-width) solid var(--wsscd-color-border-light);
}

.wsscd-schedule-summary__icon .wsscd-icon {
    color: var(--wsscd-color-primary);
}

.wsscd-schedule-summary__description {
    font-size: var(--wsscd-font-size-medium);
    font-weight: var(--wsscd-font-weight-medium);
    color: var(--wsscd-color-text);
    line-height: 1.4;
}

/* ==========================================================================
   Recurrence Rule Controls
   ========================================================================== */

/* The rule builder sits on a quiet inset panel so the three questions
   (Active on / Time of day / Keep running) read as one form ladder and the
   white preview card below it stands out as the payoff. */
.wsscd-recurring-config {
    padding: var(--wsscd-spacing-lg);
    background: var(--wsscd-color-surface);
    border: var(--wsscd-border-width) solid var(--wsscd-color-border-subtle);
    border-radius: var(--wsscd-radius-lg);
}

.wsscd-rule-row {
    display: grid;
    grid-template-columns: 128px 1fr;
    align-items: center;
    gap: var(--wsscd-spacing-sm) var(--wsscd-spacing-md);
    margin: 0;
    padding: var(--wsscd-spacing-md) 0;
}

/* Hairline between question groups — not before continuation rows, so a
   question and its chips read as one unit. */
.wsscd-rule-row + .wsscd-rule-row:not(.wsscd-weekday-chips):not(.wsscd-month-day-grid):not(.wsscd-window-times) {
    border-top: var(--wsscd-border-width) solid var(--wsscd-color-border-subtle);
}

.wsscd-rule-row__label {
    font-size: 11px;
    font-weight: var(--wsscd-font-weight-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--wsscd-color-text-muted);
}

/* Continuation rows (chips, month grid, window times) hang under the answer
   column of the question above them. */
.wsscd-rule-row.wsscd-weekday-chips,
.wsscd-rule-row.wsscd-month-day-grid,
.wsscd-rule-row.wsscd-window-times {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--wsscd-spacing-xs);
    margin-left: calc(128px + var(--wsscd-spacing-md));
    padding-top: 0;
    padding-bottom: var(--wsscd-spacing-md);
}

/* Segmented control track — identical to the Start toggle's track so every
   segmented control in the step matches. */
.wsscd-recurring-config .wsscd-toggle-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--wsscd-spacing-xxs);
    padding: var(--wsscd-spacing-xxs);
    background: var(--wsscd-color-white);
    border: var(--wsscd-border-width) solid var(--wsscd-color-border);
    border-radius: var(--wsscd-radius-md);
}

.wsscd-recurring-config .wsscd-toggle-btn:focus-within {
    box-shadow: var(--wsscd-ring-focus);
}

.wsscd-toggle-group .wsscd-toggle-btn.disabled,
.wsscd-schedule-type-card.disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Day chips inside the panel sit on white already (shared block above);
   give selection a little weight and hover a lift. */
.wsscd-recurring-config .wsscd-day-chip:hover {
    transform: translateY(-1px);
}

.wsscd-recurring-config .wsscd-day-chip.selected,
.wsscd-recurring-config .wsscd-day-chip:has(input[type="checkbox"]:checked) {
    box-shadow: var(--wsscd-shadow-sm);
}

/* Month-day grid — square siblings of the round weekday chips: circles are
   weekdays, squares are dates. */
.wsscd-rule-row.wsscd-month-day-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(36px, 44px));
    gap: var(--wsscd-spacing-xs);
}

.wsscd-month-chip {
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0;
    background: var(--wsscd-color-white);
    border: 2px solid var(--wsscd-color-border);
    border-radius: var(--wsscd-radius-sm);
    cursor: pointer;
    transition: var(--wsscd-transition-colors), transform var(--wsscd-transition-fast) ease;
    font-size: var(--wsscd-font-size-small);
    font-weight: var(--wsscd-font-weight-medium);
    color: var(--wsscd-color-text);
    user-select: none;
}

.wsscd-month-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.wsscd-month-chip:hover {
    border-color: var(--wsscd-color-primary);
    background: var(--wsscd-color-primary-alpha-10);
    transform: translateY(-1px);
}

.wsscd-month-chip.selected,
.wsscd-month-chip:has(input[type="checkbox"]:checked) {
    background: var(--wsscd-color-primary);
    border-color: var(--wsscd-color-primary);
    color: var(--wsscd-color-white);
    box-shadow: var(--wsscd-shadow-sm);
}

.wsscd-month-chip:focus-within {
    outline: 2px solid var(--wsscd-color-primary);
    outline-offset: 2px;
}

.wsscd-month-chip.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

/* "Last day" is a token, not a number — dashed border marks it special. */
.wsscd-month-chip--last {
    grid-column: span 2;
    border-style: dashed;
    font-weight: var(--wsscd-font-weight-semibold);
}

.wsscd-month-chip--last.selected,
.wsscd-month-chip--last:has(input[type="checkbox"]:checked) {
    border-style: solid;
}

/* Time-of-day window */
.wsscd-window-times__sep {
    font-size: 11px;
    font-weight: var(--wsscd-font-weight-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--wsscd-color-text-muted);
}

.wsscd-overnight-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border: var(--wsscd-border-width) solid var(--wsscd-color-info);
    border-radius: var(--wsscd-radius-pill);
    background: var(--wsscd-color-white);
    color: var(--wsscd-color-info);
    font-size: 11px;
    font-weight: var(--wsscd-font-weight-semibold);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Keep running (lifetime) */
.wsscd-rule-row.wsscd-lifetime {
    grid-template-columns: 128px auto 1fr;
}

.wsscd-lifetime__select {
    min-width: 150px;
    height: var(--wsscd-input-height);
    border-radius: var(--wsscd-input-border-radius);
}

.wsscd-lifetime__until {
    display: inline-flex;
    position: relative;
    align-items: center;
    gap: var(--wsscd-spacing-xs);
    justify-self: start;
}

.wsscd-lifetime__until .wsscd-date-picker {
    width: 140px;
    height: var(--wsscd-input-height);
    border-radius: var(--wsscd-input-border-radius);
    background: var(--wsscd-color-white);
}

/* Guard hint — a small white callout on the panel, never a toast. */
.wsscd-guard-hint {
    display: flex;
    align-items: flex-start;
    gap: var(--wsscd-spacing-sm);
    margin: var(--wsscd-spacing-md) 0 0;
    padding: var(--wsscd-spacing-sm) var(--wsscd-spacing-md);
    background: var(--wsscd-color-white);
    border: var(--wsscd-border-width) solid var(--wsscd-color-border-subtle);
    border-left: 3px solid var(--wsscd-color-info);
    border-radius: var(--wsscd-radius-sm);
    font-size: var(--wsscd-font-size-small);
    color: var(--wsscd-color-text);
    animation: wsscd-slide-in-down var(--wsscd-transition-base) ease;
}

.wsscd-guard-hint__icon {
    flex-shrink: 0;
    display: inline-flex;
    color: var(--wsscd-color-info);
}

.wsscd-guard-hint--error {
    border-left-color: var(--wsscd-color-danger);
}

.wsscd-guard-hint--error .wsscd-guard-hint__icon {
    color: var(--wsscd-color-danger);
}

.wsscd-guard-hint__text {
    flex: 1;
    line-height: var(--wsscd-line-height-base);
}

/* The preview card is the payoff of the panel — pull it flush with the
   panel body and let its own white card carry the emphasis. */
.wsscd-recurring-config .wsscd-schedule-summary {
    margin: var(--wsscd-spacing-lg) 0 0;
}

.wsscd-recurring-config .wsscd-schedule-summary__description {
    font-weight: var(--wsscd-font-weight-semibold);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 782px) {
    .wsscd-schedule-type-cards {
        grid-template-columns: 1fr;
        gap: var(--wsscd-spacing-md);
    }

    .wsscd-schedule-type-card {
        padding: var(--wsscd-spacing-md);
    }

    .wsscd-schedule-type-card__icon {
        width: 40px;
        height: 40px;
    }

    .wsscd-recurring-config {
        padding: var(--wsscd-spacing-md);
    }

    .wsscd-rule-row,
    .wsscd-rule-row.wsscd-lifetime {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .wsscd-rule-row.wsscd-weekday-chips,
    .wsscd-rule-row.wsscd-month-day-grid,
    .wsscd-rule-row.wsscd-window-times {
        margin-left: 0;
    }

    .wsscd-rule-row.wsscd-month-day-grid {
        grid-template-columns: repeat(7, minmax(32px, 1fr));
    }

    .wsscd-day-chip {
        width: 32px;
        height: 32px;
        font-size: var(--wsscd-font-size-small);
    }

    .wsscd-schedule-summary__text {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .wsscd-schedule-type-card__content h5 {
        font-size: var(--wsscd-font-size-small);
    }

    .wsscd-schedule-type-card__content p {
        font-size: var(--wsscd-font-size-small);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wsscd-recurring-config,
    .wsscd-guard-hint {
        animation: none;
    }

    .wsscd-recurring-config .wsscd-day-chip:hover,
    .wsscd-month-chip:hover {
        transform: none;
    }
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .wsscd-calendar-icon {
    right: auto;
    left: 8px;
}

[dir="rtl"] .wsscd-error-message {
    border-left: none;
    border-right: 4px solid var(--wsscd-color-danger);
}

[dir="rtl"] .wsscd-rule-row.wsscd-weekday-chips,
[dir="rtl"] .wsscd-rule-row.wsscd-month-day-grid,
[dir="rtl"] .wsscd-rule-row.wsscd-window-times {
    margin-left: 0;
    margin-right: calc(128px + var(--wsscd-spacing-md));
}

@media (max-width: 782px) {
    [dir="rtl"] .wsscd-rule-row.wsscd-weekday-chips,
    [dir="rtl"] .wsscd-rule-row.wsscd-month-day-grid,
    [dir="rtl"] .wsscd-rule-row.wsscd-window-times {
        margin-right: 0;
    }
}

[dir="rtl"] .wsscd-guard-hint {
    border-left: var(--wsscd-border-width) solid var(--wsscd-color-border-subtle);
    border-right: 3px solid var(--wsscd-color-info);
}

[dir="rtl"] .wsscd-guard-hint--error {
    border-right-color: var(--wsscd-color-danger);
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wsscd-card-option {
        page-break-inside: avoid;
    }
}
