/* --- GLOBAL RESET & VARS (Scoped to .tv-date-wrapper) --- */
.tv-date-wrapper,
.tv-date-wrapper *,
.tv-date-wrapper *::before,
.tv-date-wrapper *::after {
    box-sizing: border-box;
}

/* Wrapper */
.tv-date-wrapper {
    position: relative;
    display: inline-block;
    width: 250px;
    font-family: var(--ze-font-body-md-family);
    line-height: 1.5;
    text-align: left;
}

/* Label */
.tv-date-wrapper .tv-date-label {
    display: block;
    font-family: var(--ze-font-label-md-family);
    font-weight: var(--ze-font-label-md-weight);
    font-size: var(--ze-font-label-md-size);
    color: var(--ze-color-on-surface);
    margin: 0 0 5px 0;
    padding: 0;
}

/* --- TRIGGER (Dropdown Button) --- */
.tv-date-wrapper .tv-date-trigger {
    background-color: var(--ze-color-surface-container-lowest);
    border: 1px solid var(--ze-color-outline-variant);
    border-radius: var(--ze-radius-md);
    padding: 0 16px;
    font-size: 15px;
    color: var(--ze-color-on-surface);
    font-family: var(--ze-font-body-md-family);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 48px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
}

.tv-date-wrapper .tv-date-trigger:hover {
    border-color: var(--ze-color-outline);
}

.tv-date-wrapper .tv-date-trigger.is-active,
.tv-date-wrapper .tv-date-trigger.has-filter {
    border-color: var(--ze-color-secondary);
    box-shadow: 0 0 0 4px var(--ze-color-surface-container);
    background-color: var(--ze-color-surface-container-lowest);
}

.tv-date-wrapper .tv-date-trigger-icon {
    color: var(--ze-color-on-surface-variant);
    font-size: 20px;
    line-height: 1;
    transition: color 0.2s ease;
}

.tv-date-wrapper .tv-date-trigger.is-active .tv-date-trigger-icon,
.tv-date-wrapper .tv-date-trigger.has-filter .tv-date-trigger-icon {
    color: var(--ze-color-secondary);
}

.tv-date-wrapper .tv-date-trigger-text.has-value {
    font-weight: 600;
    color: var(--ze-color-on-surface);
}

/* --- DROPDOWN CONTAINER --- */
.tv-date-wrapper .tv-date-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1000;
    width: 500px;
    background-color: var(--ze-color-surface-container-lowest);
    border-radius: var(--ze-radius-md);
    box-shadow: var(--ze-shadow-level-2);
    border: 1px solid var(--ze-color-outline-variant);
    display: none;
    animation: dnFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    margin: 0;
    padding: 0;
    overflow: visible;
}

.tv-date-wrapper .tv-date-dropdown.is-visible {
    display: block;
}

@keyframes dnFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Body Layout (Split) */
.tv-date-wrapper .tv-date-body {
    display: flex;
    border-bottom: 1px solid var(--ze-color-outline-variant);
}

/* Sidebar */
.tv-date-wrapper .tv-date-sidebar {
    width: 200px;
    background-color: transparent;
    border-right: 1px solid var(--ze-color-outline-variant);
    padding: 12px 0;
    flex-shrink: 0;
}

.tv-date-wrapper .tv-preset-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tv-date-wrapper .tv-preset-item {
    padding: 10px 20px;
    font-size: 14px;
    font-family: var(--ze-font-body-md-family);
    color: var(--ze-color-on-surface-variant);
    cursor: pointer;
    position: relative;
    margin: 2px 8px;
    border-radius: var(--ze-radius-sm);
    line-height: 1.4;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tv-date-wrapper .tv-preset-item:hover {
    background-color: var(--ze-color-surface-container-low);
    color: var(--ze-color-on-surface);
}

.tv-date-wrapper .tv-preset-item.is-active {
    color: var(--ze-color-primary);
    background-color: var(--ze-color-surface-container);
    font-weight: 600;
}

.tv-date-wrapper .tv-preset-item.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    border-radius: var(--ze-radius-full);
    background-color: var(--ze-color-secondary);
}

.tv-date-wrapper .preset-arrow {
    font-size: 18px;
    color: var(--ze-color-outline-variant);
    transition: transform 0.2s ease, color 0.2s ease;
}

.tv-preset-item:hover .preset-arrow {
    color: var(--ze-color-on-surface);
    transform: translateX(2px);
}

.tv-preset-item.is-active .preset-arrow {
    color: var(--ze-color-secondary);
}

/* Custom Panel */
.tv-date-wrapper .tv-date-custom-panel {
    flex-grow: 1;
    padding: 20px;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tv-date-wrapper .tv-date-input-group {
    margin-bottom: 20px;
    position: relative;
}

.tv-date-wrapper .tv-date-input-group:last-child {
    margin-bottom: 0;
}

/* --- CUSTOM INPUT BOX STYLE --- */
.tv-date-wrapper .tv-custom-input-wrapper {
    position: relative;
    border: 1px solid var(--ze-color-outline-variant);
    border-radius: var(--ze-radius-md);
    height: 52px;
    background-color: var(--ze-color-surface-container-low);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
}

.tv-date-wrapper .tv-custom-input-wrapper:hover {
    border-color: var(--ze-color-outline);
}

.tv-date-wrapper .tv-custom-input-wrapper.is-focused {
    border-color: var(--ze-color-secondary);
    box-shadow: 0 0 0 4px var(--ze-color-surface-container);
    background-color: var(--ze-color-surface-container-lowest);
}

/* Label (Nach/Vor) */
.tv-date-wrapper .tv-floating-label {
    font-family: var(--ze-font-label-sm-family);
    font-size: 11px;
    color: var(--ze-color-on-surface-variant);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
    line-height: 1;
    display: block;
}

.tv-date-wrapper .tv-custom-input-wrapper.is-focused .tv-floating-label {
    color: var(--ze-color-secondary);
}

/* Input Field */
.tv-date-wrapper .tv-custom-input {
    -webkit-appearance: none;
    appearance: none;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;

    width: 100%;
    font-family: var(--ze-font-body-md-family);
    font-size: 14px;
    color: var(--ze-color-on-surface);

    margin: 0 !important;
    padding: 0 !important;
    line-height: normal !important;
    height: auto !important;

    cursor: pointer;
}

.tv-date-wrapper .tv-input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ze-color-on-surface-variant);
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
    transition: color 0.2s ease;
}

.tv-date-wrapper .tv-custom-input-wrapper.is-focused .tv-input-icon {
    color: var(--ze-color-secondary);
}

/* --- CUSTOM CALENDAR POPUP --- */
.tv-date-wrapper .tv-calendar-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 280px;
    background: var(--ze-color-surface-container-lowest);
    border: 1px solid var(--ze-color-outline-variant);
    border-radius: var(--ze-radius-md);
    box-shadow: var(--ze-shadow-level-2);
    padding: 16px;
    z-index: 2000;
    display: none;
    margin: 0;
}

.tv-date-wrapper .tv-calendar-popup.is-open {
    display: block;
}

/* Calendar Header */
.tv-date-wrapper .tv-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tv-date-wrapper .tv-cal-month-year {
    font-family: var(--ze-font-headline-sm-family);
    font-weight: 700;
    color: var(--ze-color-on-surface);
    font-size: 16px;
    margin: 0;
}

.tv-date-wrapper .tv-cal-nav {
    display: flex;
    gap: 8px;
    margin: 0;
}

.tv-date-wrapper .tv-cal-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--ze-color-on-surface-variant);
    font-size: 18px;
    padding: 4px;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ze-radius-sm);
    transition: all 0.2s ease;
}

.tv-date-wrapper .tv-cal-btn:hover {
    color: var(--ze-color-on-surface);
    background-color: var(--ze-color-surface-container);
}

/* Grid */
.tv-date-wrapper .tv-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
    align-items: center;
    justify-items: center;
    margin: 0;
    padding: 0;
}

.tv-date-wrapper .tv-cal-day-label {
    font-family: var(--ze-font-label-sm-family);
    font-size: 11px;
    color: var(--ze-color-on-surface-variant);
    margin-bottom: 6px;
    font-weight: 600;
    line-height: 1;
    width: 32px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-date-wrapper .tv-cal-day {
    font-family: var(--ze-font-body-sm-family);
    font-size: 13px;
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--ze-color-on-surface);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tv-date-wrapper .tv-cal-day:hover:not(.is-empty):not(.is-disabled) {
    background-color: var(--ze-color-surface-container);
}

.tv-date-wrapper .tv-cal-day.is-selected {
    background-color: var(--ze-color-secondary);
    color: var(--ze-color-on-secondary);
    font-weight: 600;
}

.tv-date-wrapper .tv-cal-day.is-today {
    color: var(--ze-color-secondary);
    font-weight: 700;
    border: 1px solid var(--ze-color-secondary);
}

.tv-date-wrapper .tv-cal-day.is-selected.is-today {
    color: var(--ze-color-on-secondary);
    background-color: var(--ze-color-secondary);
}

.tv-date-wrapper .tv-cal-day.is-empty {
    cursor: default;
}

.tv-date-wrapper .tv-cal-day.is-disabled {
    color: var(--ze-color-outline-variant);
    background-color: transparent;
    cursor: not-allowed;
    pointer-events: none;
    text-decoration: line-through;
    opacity: 0.5;
}

/* Calendar Footer */
.tv-date-wrapper .tv-cal-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    border-top: 1px solid var(--ze-color-outline-variant);
    padding-top: 12px;
}

.tv-date-wrapper .tv-cal-footer-btn {
    background: transparent;
    border: none;
    font-family: var(--ze-font-body-md-family);
    font-size: 12px;
    color: var(--ze-color-outline);
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    margin: 0;
    line-height: 1;
    box-shadow: none !important;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tv-date-wrapper .tv-cal-footer-btn:hover {
    color: var(--ze-color-primary);
}

.tv-date-wrapper .tv-cal-footer-btn.is-delete {
    color: var(--ze-color-error);
}

.tv-date-wrapper .tv-cal-footer-btn.is-delete:hover {
    color: #a61313;
}

/* --- FOOTER ACTIONS --- */
.tv-date-wrapper .tv-date-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: transparent;
    margin: 0;
    border-top: 1px solid var(--ze-color-outline-variant);
}

.tv-date-wrapper .tv-footer-actions {
    display: flex;
    gap: 12px;
    margin: 0;
}

.tv-date-wrapper .tv-date-footer button {
    font-family: var(--ze-font-body-md-family);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    margin: 0;
    line-height: normal;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tv-date-wrapper .tv-btn-clear {
    background: transparent;
    color: var(--ze-color-error);
    padding: 0;
}
.tv-date-wrapper .tv-btn-clear:hover {
    text-decoration: underline;
    color: #a61313;
}

.tv-date-wrapper .tv-btn-cancel {
    background: transparent;
    color: var(--ze-color-on-surface-variant);
    border: 1px solid var(--ze-color-outline-variant);
    padding: 10px 24px;
    border-radius: var(--ze-radius-full);
}
.tv-date-wrapper .tv-btn-cancel:hover {
    background-color: var(--ze-color-surface-container);
    border-color: var(--ze-color-outline);
    color: var(--ze-color-on-surface);
    transform: translateY(-2px);
}
.tv-date-wrapper .tv-btn-cancel:active {
    transform: translateY(0);
}

.tv-date-wrapper .tv-btn-apply {
    background-color: var(--ze-color-primary);
    color: var(--ze-color-on-primary);
    padding: 10px 24px;
    border-radius: var(--ze-radius-full);
    box-shadow: var(--ze-shadow-level-1);
}
.tv-date-wrapper .tv-btn-apply:hover {
    background-color: var(--ze-color-secondary);
    color: var(--ze-color-on-secondary);
    transform: translateY(-2px);
    box-shadow: var(--ze-shadow-level-2);
}
.tv-date-wrapper .tv-btn-apply:active {
    transform: translateY(0);
}

/* --- RESPONSIVE: TABLET & MOBILE --- */
@media screen and (max-width: 1024px) {

    .tv-date-wrapper {
        width: 100%;
        display: block;
        margin-bottom: 10px;
    }

    .tv-date-wrapper .tv-date-dropdown {
        width: 100%;
        min-width: auto;
        left: 0 !important;
        right: 0 !important;
        position: absolute;
    }

    .tv-date-wrapper .tv-date-body {
        flex-direction: column;
    }

    .tv-date-wrapper .tv-date-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--ze-color-outline-variant);
        padding: 8px;
    }

    .tv-date-wrapper .tv-preset-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0 8px;
    }

    .tv-date-wrapper .tv-preset-item {
        flex: 1 0 auto;
        text-align: center;
        border-radius: var(--ze-radius-sm);
        padding: 8px 12px;
        margin: 0;
        border: 1px solid var(--ze-color-outline-variant);
        justify-content: center;
    }

    .tv-date-wrapper .tv-preset-item.is-active::before {
        display: none;
    }

    .tv-date-wrapper .preset-arrow {
        display: none;
    }

    .tv-date-wrapper .tv-date-custom-panel {
        padding: 15px;
    }

    .tv-date-wrapper .tv-calendar-popup {
        width: 280px;
        max-width: none;
    }
}