:root {
    --dga-time-picker-bg: var(--dga-color-bg-primary, #ffffff);
    --dga-time-picker-surface: var(--dga-color-bg-secondary, #f9fafb);
    --dga-time-picker-surface-strong: var(--dga-color-bg-tertiary, #f3f6f5);

    --dga-time-picker-text: var(--dga-color-text-primary, #111827);
    --dga-time-picker-text-muted: var(--dga-color-text-secondary, #4b5563);
    --dga-time-picker-placeholder: var(--dga-color-text-placeholder, #6b7280);

    --dga-time-picker-border: var(--dga-color-border-neutral-primary, #d2d6db);
    --dga-time-picker-border-hover: var(--dga-color-border-primary, #1b8354);

    --dga-time-picker-primary: var(--dga-color-primary, #1b8354);
    --dga-time-picker-primary-hover: var(--dga-color-primary-hover, #166a45);
    --dga-time-picker-primary-soft: var(--dga-color-primary-50, #ecfdf3);
    --dga-time-picker-primary-soft-2: var(--dga-color-primary-100, #d3f8df);

    --dga-time-picker-danger: var(--dga-color-error, #d92d20);
    --dga-time-picker-disabled-bg: var(--dga-color-bg-disabled, #f3f4f6);
    --dga-time-picker-disabled-text: var(--dga-color-text-disabled, #9ca3af);

    --dga-time-picker-radius-sm: 8px;
    --dga-time-picker-radius-md: 12px;
    --dga-time-picker-radius-lg: 16px;

    --dga-time-picker-shadow: 0 18px 44px rgba(16, 24, 40, 0.16);
    --dga-time-picker-focus-ring: 0 0 0 3px rgba(27, 131, 84, 0.18);
}

.dga-time-picker,
.dga-time-picker * {
    box-sizing: border-box;
}

.dga-time-picker {
    position: relative;
    display: inline-block;
    width: 100%;
    color: var(--dga-time-picker-text);
}

.dga-time-picker__input-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.dga-time-picker__input {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    padding-inline-end: 44px;
    border: 1px solid var(--dga-time-picker-border);
    border-radius: var(--dga-time-picker-radius-sm);
    background: var(--dga-time-picker-bg);
    color: var(--dga-time-picker-text);
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.dga-time-picker__input::placeholder {
    color: var(--dga-time-picker-placeholder);
}

.dga-time-picker__input:hover:not(:disabled) {
    border-color: var(--dga-time-picker-border-hover);
}

.dga-time-picker__input:focus,
.dga-time-picker__input:focus-visible {
    outline: none;
    border-color: var(--dga-time-picker-primary);
    box-shadow: var(--dga-time-picker-focus-ring);
}

.dga-time-picker--large .dga-time-picker__input {
    min-height: 48px;
    font-size: 16px;
}

.dga-time-picker__input:disabled,
.dga-time-picker--disabled .dga-time-picker__input {
    cursor: not-allowed;
    background: var(--dga-time-picker-disabled-bg);
    color: var(--dga-time-picker-disabled-text);
}

.dga-time-picker--invalid .dga-time-picker__input,
.dga-time-picker__input--invalid {
    border-color: var(--dga-time-picker-danger);
}

.dga-time-picker__icon {
    position: absolute;
    inset-inline-end: 14px;
    width: 18px;
    height: 18px;
    color: var(--dga-time-picker-text-muted);
    pointer-events: none;
}

.dga-time-picker__icon::before {
    content: "";
    position: absolute;
    inset: 1px;
    border: 1.8px solid currentColor;
    border-radius: 50%;
}

.dga-time-picker__icon::after {
    content: "";
    position: absolute;
    left: 8px;
    top: 4px;
    width: 1.8px;
    height: 7px;
    background: currentColor;
    border-radius: 999px;
    box-shadow: 4px 6px 0 -1px currentColor;
}

.dga-time-picker__clear {
    position: absolute;
    inset-inline-end: 38px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--dga-time-picker-text-muted);
    cursor: pointer;
}

.dga-time-picker__clear:hover {
    background: var(--dga-time-picker-surface-strong);
    color: var(--dga-time-picker-text);
}

.dga-time-picker__clear::before,
.dga-time-picker__clear::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 10px;
    width: 10px;
    height: 1.6px;
    border-radius: 999px;
    background: currentColor;
}

.dga-time-picker__clear::before {
    transform: rotate(45deg);
}

.dga-time-picker__clear::after {
    transform: rotate(-45deg);
}

/* Popup */

.dga-time-picker__backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: transparent;
}

.dga-time-picker__popup {
    position: absolute;
    top: 100%;
    inset-inline-start: 0;
    z-index: 1000;

    width: 100%;
    max-width: calc(100vw - 24px);
    margin-top: 8px;

    display: flex;
    flex-direction: column;
    overflow: hidden;

    background: var(--dga-time-picker-bg);
    border: 1px solid var(--dga-time-picker-border);
    border-radius: 18px;
    box-shadow: var(--dga-time-picker-shadow);
}

[dir="rtl"] .dga-time-picker__popup,
.dga-time-picker--rtl .dga-time-picker__popup {
    inset-inline-start: auto;
    inset-inline-end: 0;
}

/* Header */

.dga-time-picker__header {
    padding: 20px 24px 8px;
}

.dga-time-picker__title {
    display: block;
    color: var(--dga-time-picker-text-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

/* Body */

.dga-time-picker__body {
    gap: 24px;
    align-items: center;
    padding: 12px 24px 22px;
    min-height: 330px;
}

.dga-time-picker__body--manual-only {
    grid-template-columns: 1fr;
    min-height: auto;
}

.dga-time-picker__body--manual-only .dga-time-picker__selector {
    display: none;
}

[dir="rtl"] .dga-time-picker__body,
.dga-time-picker--rtl .dga-time-picker__body {
    direction: rtl;
}

/* Left side */

.dga-time-picker__control {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Digital display */

.dga-time-picker__display {
    direction: ltr;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.dga-time-picker__display-part {
    width: 112px;
    height: 92px;
    padding: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid var(--dga-time-picker-border);
    border-radius: 16px;
    background: var(--dga-time-picker-surface);

    color: var(--dga-time-picker-text);
    font-size: 54px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;

    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.dga-time-picker__display-part:hover:not(:disabled) {
    border-color: var(--dga-time-picker-primary);
    background: var(--dga-time-picker-primary-soft);
}

.dga-time-picker__display-part:focus-visible {
    outline: none;
    box-shadow: var(--dga-time-picker-focus-ring);
}

.dga-time-picker__display-part--active {
    border-color: var(--dga-time-picker-primary);
    background: var(--dga-time-picker-primary-soft);
    color: var(--dga-time-picker-primary);
    box-shadow: inset 0 0 0 2px var(--dga-time-picker-primary);
}

.dga-time-picker__display-part:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.dga-time-picker__display-sep {
    color: var(--dga-time-picker-text);
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
}

.dga-time-picker__display-period {
    min-width: 40px;
    height: 36px;
    padding: 0 10px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid var(--dga-time-picker-border);
    border-radius: 999px;
    background: var(--dga-time-picker-bg);

    color: var(--dga-time-picker-text-muted);
    font-size: 14px;
    font-weight: 700;
}

/* Segmented controls */

.dga-time-picker__system {
    display: flex;
    width: 100%;
    gap: 0;
    padding: 4px;

    border: 1px solid var(--dga-time-picker-border);
    border-radius: 16px;
    background: var(--dga-time-picker-surface);
}

.dga-time-picker__system-option {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;

    border: 0;
    border-radius: 12px;
    background: transparent;

    color: var(--dga-time-picker-text-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;

    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.dga-time-picker__system-option:hover:not(:disabled) {
    background: var(--dga-time-picker-bg);
    color: var(--dga-time-picker-primary);
}

.dga-time-picker__system-option:focus-visible {
    outline: none;
    box-shadow: var(--dga-time-picker-focus-ring);
}

.dga-time-picker__system-option--selected {
    background: var(--dga-time-picker-bg);
    color: var(--dga-time-picker-primary);
    font-weight: 800;
    box-shadow:
            0 1px 4px rgba(16, 24, 40, 0.12),
            inset 0 0 0 1px var(--dga-time-picker-primary);
}

.dga-time-picker__system-option:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* Manual input */

.dga-time-picker__manual-input {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;

    border: 1px solid var(--dga-time-picker-border);
    border-radius: 12px;
    background: var(--dga-time-picker-bg);

    color: var(--dga-time-picker-text);
    font-size: 15px;
}

.dga-time-picker__manual-input:focus,
.dga-time-picker__manual-input:focus-visible {
    outline: none;
    border-color: var(--dga-time-picker-primary);
    box-shadow: var(--dga-time-picker-focus-ring);
}

.dga-time-picker__manual-input--invalid {
    border-color: var(--dga-time-picker-danger);
}

/* Right side */

.dga-time-picker__selector {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dga-time-picker__selector-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.dga-time-picker__selector-panel--wheel {
    justify-content: center;
}

.dga-time-picker__selector-label {
    color: var(--dga-time-picker-text-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

/* Wheel selector */

.dga-time-picker__wheel-picker {
    direction: ltr;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 238px;
}

.dga-time-picker__wheel-picker--12 {
    gap: 10px;
}

.dga-time-picker__wheel-column {
    position: relative;
    width: 82px;
    min-width: 82px;
    height: 224px;
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    align-items: center;
    justify-items: stretch;
    padding: 0 4px;
}

.dga-time-picker__wheel-column--period {
    width: 76px;
    min-width: 76px;
}

.dga-time-picker__wheel-column::before,
.dga-time-picker__wheel-column::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    height: 40px;
    z-index: 2;
    pointer-events: none;
}

.dga-time-picker__wheel-column::before {
    top: 0;
    background: linear-gradient(to bottom, var(--dga-time-picker-bg) 0%, rgba(255, 255, 255, 0) 100%);
}

.dga-time-picker__wheel-column::after {
    bottom: 0;
    background: linear-gradient(to top, var(--dga-time-picker-bg) 0%, rgba(255, 255, 255, 0) 100%);
}

.dga-time-picker__wheel-highlight {
    position: absolute;
    inset-inline: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 42px;
    border-radius: 10px;
    background: rgba(17, 24, 39, 0.10);
    z-index: 0;
    pointer-events: none;
}

.dga-time-picker__wheel-item {
    position: relative;
    z-index: 1;
    min-height: 32px;
    border: 0;
    background: transparent;
    color: var(--dga-time-picker-text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    transition:
            color 160ms ease,
            opacity 160ms ease,
            transform 160ms ease,
            font-size 160ms ease,
            font-weight 160ms ease;
}

.dga-time-picker__wheel-item:hover:not(:disabled) {
    color: var(--dga-time-picker-primary);
}

.dga-time-picker__wheel-item:focus-visible {
    outline: none;
    color: var(--dga-time-picker-primary);
}

.dga-time-picker__wheel-item:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.dga-time-picker__wheel-item--selected {
    color: var(--dga-time-picker-text);
    font-size: 24px;
    font-weight: 800;
    transform: scale(1.02);
}

.dga-time-picker__wheel-item--period.dga-time-picker__wheel-item--selected {
    font-size: 22px;
}

.dga-time-picker__wheel-item--depth-1 {
    font-size: 18px;
    font-weight: 700;
    opacity: 0.80;
}

.dga-time-picker__wheel-item--depth-2 {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.55;
}

.dga-time-picker__wheel-item--depth-3 {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.30;
}

.dga-time-picker__wheel-separator {
    align-self: center;
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    color: var(--dga-time-picker-text);
    padding-bottom: 2px;
}

/* Footer */

.dga-time-picker__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 16px 24px;
    border-top: 1px solid var(--dga-time-picker-border);
    background: var(--dga-time-picker-bg);
}

.dga-time-picker__action {
    flex: 0 0 auto;
}

.dga-time-picker__footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-inline-start: auto;
}

[dir="rtl"] .dga-time-picker__footer-actions,
.dga-time-picker--rtl .dga-time-picker__footer-actions {
    margin-inline-start: 0;
    margin-inline-end: auto;
}

/* Responsive */

@media (max-width: 760px) {
    .dga-time-picker__body {
        grid-template-columns: 1fr;
        gap: 22px;
        min-height: auto;
    }

    .dga-time-picker__display {
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .dga-time-picker__popup {
        position: fixed;
        top: auto;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 24px);
    }

    [dir="rtl"] .dga-time-picker__popup,
    .dga-time-picker--rtl .dga-time-picker__popup {
        left: 12px;
        right: 12px;
        inset-inline-start: 12px;
        inset-inline-end: 12px;
    }

    .dga-time-picker__header {
        padding: 18px 18px 8px;
    }

    .dga-time-picker__body {
        padding: 12px 18px 18px;
    }

    .dga-time-picker__display-part {
        width: 90px;
        height: 76px;
        font-size: 42px;
    }

    .dga-time-picker__display-sep {
        font-size: 40px;
    }

    .dga-time-picker__display-period {
        height: 32px;
        min-width: 34px;
        font-size: 12px;
    }

    .dga-time-picker__wheel-picker {
        gap: 8px;
        min-height: 210px;
    }

    .dga-time-picker__wheel-column {
        width: 66px;
        min-width: 66px;
        height: 196px;
    }

    .dga-time-picker__wheel-column--period {
        width: 58px;
        min-width: 58px;
    }

    .dga-time-picker__wheel-highlight {
        height: 38px;
        top: 56%;
    }

    .dga-time-picker__wheel-item--selected {
        font-size: 20px;
    }

    .dga-time-picker__wheel-item--period.dga-time-picker__wheel-item--selected {
        font-size: 18px;
    }

    .dga-time-picker__wheel-item--depth-1 {
        font-size: 16px;
    }

    .dga-time-picker__wheel-item--depth-2 {
        font-size: 13px;
    }

    .dga-time-picker__wheel-item--depth-3 {
        font-size: 11px;
    }

    .dga-time-picker__wheel-separator {
        font-size: 24px;
    }

    .dga-time-picker__footer {
        padding: 14px 18px 18px;
        flex-wrap: wrap;
    }

    .dga-time-picker__footer-actions {
        width: 100%;
        justify-content: stretch;
    }

    .dga-time-picker__footer-actions > * {
        flex: 1 1 0;
    }
}

/* AM/PM wheel: only two options */
.dga-time-picker__wheel-column--period-two {
    width: 76px;
    min-width: 76px;
    height: 96px;
    display: grid;
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    padding: 4px;
    border-radius: 14px;
    background: var(--dga-time-picker-surface);
}

.dga-time-picker__wheel-column--period-two::before,
.dga-time-picker__wheel-column--period-two::after,
.dga-time-picker__wheel-column--period-two .dga-time-picker__wheel-highlight {
    display: none;
}

.dga-time-picker__wheel-column--period-two .dga-time-picker__wheel-item--period {
    min-height: 40px;
    border-radius: 10px;
    color: var(--dga-time-picker-text-muted);
    font-size: 14px;
    font-weight: 700;
    opacity: 1;
    transform: none;
}

.dga-time-picker__wheel-column--period-two .dga-time-picker__wheel-item--period:hover:not(:disabled),
.dga-time-picker__wheel-column--period-two .dga-time-picker__wheel-item--period:focus-visible {
    outline: none;
    background: var(--dga-time-picker-bg);
    color: var(--dga-time-picker-primary);
}

.dga-time-picker__wheel-column--period-two .dga-time-picker__wheel-item--period.dga-time-picker__wheel-item--selected {
    background: var(--dga-time-picker-bg);
    color: var(--dga-time-picker-primary);
    font-size: 16px;
    font-weight: 800;
    box-shadow:
            0 1px 4px rgba(16, 24, 40, 0.12),
            inset 0 0 0 1px var(--dga-time-picker-primary);
}

/* Locked minute wheel used when AllowMinutes=false */
.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute {
    position: relative !important;
    width: 82px !important;
    min-width: 82px !important;
    height: 224px !important;

    display: flex !important;
    grid-template-rows: none !important;
    align-items: center !important;
    justify-content: center !important;
    justify-items: center !important;

    padding: 0 4px !important;
}

.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute::before,
.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute::after,
.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute .dga-time-picker__wheel-highlight {
    display: none !important;
}

.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute .dga-time-picker__wheel-item {
    position: static !important;
    z-index: 1;

    width: 100% !important;
    min-height: 42px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    border-radius: 10px;
    opacity: 1 !important;
    cursor: default;
    transform: none !important;
}

.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute .dga-time-picker__wheel-item:disabled {
    opacity: 1 !important;
    color: var(--dga-time-picker-text) !important;
    background: transparent !important;
}

.dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute .dga-time-picker__wheel-item--selected {
    color: var(--dga-time-picker-text) !important;
    font-size: 24px !important;
    transform: none !important;
}

@media (max-width: 520px) {
    .dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute {
        width: 66px !important;
        min-width: 66px !important;
        height: 196px !important;
    }

    .dga-time-picker__wheel-picker .dga-time-picker__wheel-column--locked-minute .dga-time-picker__wheel-item--selected {
        font-size: 20px !important;
    }
}
