/**
 * Nice DatePicker - 现代日期时间选择器
 * @version 1.0.0
 * @author Your Name
 */

:root {
    /* 🎨 现代配色 */
    --ndp-bg: #ffffff;
    --ndp-text-main: #1d1d1f;
    --ndp-text-sub: #86868b;
    --ndp-text-disabled: #d2d2d7;
    --ndp-accent: #007aff;
    --ndp-accent-bg: rgba(0, 122, 255, 0.1);
    --ndp-hover: #f5f5f7;
    --ndp-border: #e5e5ea;
    --ndp-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.04);
    --ndp-radius: 16px;
    --ndp-anim: cubic-bezier(0.2, 0.8, 0.2, 1);

    /* 📐 尺寸变量 */
    --ndp-w: 320px;
    --ndp-viewport-h: 260px;
    --ndp-header-h: 44px;
    --ndp-item-h: 36px;
}

/* 数字等宽字体 */
/* .lgnewui-time-value,
.ndp-time-item,
.ndp-day-cell,
.ndp-year-item,
.ndp-month-item,
.ndp-title-btn {
    font-family: "DM Mono", "SF Mono", "Menlo", monospace;
} */

/* --- 触发器 (lgnewui-time) --- */
.lgnewui-time-trigger {
    height: 42px;
    background: #f9fafb;
    border-radius: 8px;
    border: none;
    padding: 0 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: background-color 0.2s ease;
}

.lgnewui-time-trigger:hover {
    background: #f3f4f6;
}

.lgnewui-time-trigger.active {
    background: #f3f4f6;
}

.lgnewui-time-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lgnewui-time-prefix {
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.lgnewui-time-trigger:hover .lgnewui-time-prefix,
.lgnewui-time-trigger.active .lgnewui-time-prefix {
    color: #6b7280;
}

@keyframes iconBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.lgnewui-time-prefix.bounce {
    animation: iconBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #808080;
}

.lgnewui-time-value {
    font-size: 14px;
    font-weight: 600;
    color: #808080;
    display: inline-block;
    will-change: transform, opacity, color;
}

.lgnewui-time-value.placeholder {
    color: #9ca3af;
    font-weight: 400;
}

@keyframes valueSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
        color: #9ca3af;
    }
    50% {
        opacity: 1;
        color: #6b7280;
    }
    100% {
        opacity: 1;
        transform: translateX(0);
        color: #374151;
    }
}

.lgnewui-time-value.animating {
    animation: valueSlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.lgnewui-time-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.lgnewui-time-trigger:hover .lgnewui-time-icon {
    background: #111;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.lgnewui-time-trigger.active .lgnewui-time-icon {
    background: #111;
    color: #fff;
}

/* --- 弹窗容器 --- */
.ndp-popover {
    position: fixed;
    width: var(--ndp-w);
    max-width: calc(100vw - 24px);
    background: var(--ndp-bg);
    border-radius: var(--ndp-radius);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 16px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.96) translateY(-8px);
    transition: opacity 0.25s, transform 0.3s var(--ndp-anim), visibility 0.25s;
    box-sizing: border-box;
    user-select: none;
    overflow: hidden;
    overscroll-behavior: contain;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.ndp-popover.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.ndp-popover.place-top {
    transform-origin: bottom center;
    margin-bottom: 12px;
}

.ndp-popover.place-bottom {
    transform-origin: top center;
    margin-top: 12px;
}

/* --- 头部 --- */
.ndp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    height: 36px;
}

.ndp-title-btn {
    font-size: 16px;
    font-weight: 600;
    color: var(--ndp-text-main);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: 0.2s;
    letter-spacing: 0.3px;
}

.ndp-title-btn:hover {
    background: var(--ndp-hover);
    color: var(--ndp-accent);
}

.ndp-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: var(--ndp-text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.ndp-nav-btn:hover:not(:disabled) {
    background: var(--ndp-hover);
    transform: scale(1.05);
}

.ndp-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- 视图容器 --- */
.ndp-viewport {
    position: relative;
    height: var(--ndp-viewport-h);
    overflow: hidden;
}

.ndp-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ndp-bg);
    transition: transform 0.3s var(--ndp-anim), opacity 0.25s;
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
    display: flex;
    flex-direction: column;
}

.ndp-view.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}


/* ==================== 1. 日历视图 ==================== */
.ndp-week-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.ndp-week-day {
    text-align: center;
    font-size: 12px;
    color: var(--ndp-text-sub);
    font-weight: 600;
}

.ndp-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    row-gap: 2px;
    height: 100%;
    align-content: start;
    padding-top: 4px;
}

.ndp-day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--ndp-text-main);
    position: relative;
    transition: all 0.15s;
    font-weight: 500;
    gap: 0;
    line-height: 1.1;
}

.ndp-day-cell .lunar {
    font-size: 8px;
    color: var(--ndp-text-sub);
    font-weight: 400;
    font-family: "Inter", "PingFang SC", sans-serif;
    opacity: 0.7;
}

.ndp-day-cell.selected .lunar {
    color: rgba(255, 255, 255, 0.75);
}

.ndp-day-cell.other-month .lunar {
    opacity: 0.4;
}

.ndp-day-cell:hover:not(.disabled):not(.selected) {
    background: var(--ndp-hover);
}

.ndp-day-cell.other-month {
    color: var(--ndp-text-disabled);
    font-weight: 400;
}

.ndp-day-cell.today {
    color: var(--ndp-accent);
    font-weight: 700;
}

.ndp-day-cell.selected {
    background: var(--ndp-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.25);
    transform: scale(0.95);
}

.ndp-day-cell.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* ==================== 2. 时间视图 ==================== */
.ndp-time-header {
    height: 44px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 8px;
    gap: 4px;
    margin-bottom: 4px;
}

.ndp-time-header .ndp-header-label {
    flex: 1;
    max-width: 80px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: #7b7b7b4f;
    border-radius: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.ndp-time-header .ndp-header-separator {
    width: 16px;
    flex-shrink: 0;
}

.ndp-time-body {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow: hidden;
    padding: 0 8px;
    gap: 4px;
    mask-image: linear-gradient(to bottom,
            transparent 0%,
            rgba(0, 0, 0, 0.3) 15%,
            black 30%,
            black 70%,
            rgba(0, 0, 0, 0.3) 85%,
            transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom,
            transparent 0%,
            rgba(0, 0, 0, 0.3) 15%,
            black 30%,
            black 70%,
            rgba(0, 0, 0, 0.3) 85%,
            transparent 100%);
}

.ndp-time-highlight {
    position: absolute;
    left: 16px;
    right: 16px;
    height: 44px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 12px;
    pointer-events: none;
}

.ndp-time-highlight::after,
.ndp-time-highlight::before {
    content: '';
    position: absolute;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ndp-accent), transparent);
    animation: breath 3s ease-in-out infinite;
}

.ndp-time-highlight::before {
    top: 0;
}

.ndp-time-highlight::after {
    bottom: 0;
}

.ndp-time-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--ndp-accent);
    opacity: 0.6;
    z-index: 2;
    width: 16px;
    flex-shrink: 0;
}

.ndp-time-col {
    flex: 1;
    max-width: 80px;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    scroll-snap-type: y mandatory;
    text-align: center;
    z-index: 1;
    transform: translateZ(0);
    touch-action: pan-y;
    overscroll-behavior: contain;
    overflow-x: hidden;
    position: relative;
}

.ndp-time-col::-webkit-scrollbar {
    display: none;
}

.ndp-spacer {
    height: 90px;
    flex-shrink: 0;
}

.ndp-time-item {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 500;
    color: var(--ndp-text-main);
    opacity: 0.25;
    cursor: pointer;
    scroll-snap-align: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    margin: 0 4px;
}

.ndp-time-item:hover:not(.disabled):not(.active) {
    opacity: 0.5;
    background: rgba(0, 0, 0, 0.03);
}

.ndp-time-item.active {
    opacity: 1;
    font-weight: 700;
    font-size: 24px;
    color: var(--ndp-accent);
    transform: scale(1.05);
    text-shadow: 0 1px 2px rgba(0, 122, 255, 0.2);
}

.ndp-time-item.disabled {
    opacity: 0.1 !important;
    text-decoration: line-through;
    pointer-events: none;
    color: #ff3b30 !important;
}

/* ==================== 3. 年月视图 ==================== */
.ndp-ym-container {
    display: flex;
    flex-direction: row;
    height: 100%;
}

.ndp-year-list {
    width: 100px;
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    scrollbar-width: none;
    scroll-snap-type: y mandatory;
    text-align: center;
    mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    touch-action: pan-y;
    overscroll-behavior: contain;
    overflow-x: hidden;
}

.ndp-year-list::-webkit-scrollbar {
    display: none;
}

.ndp-year-spacer {
    height: 110px;
    flex-shrink: 0;
}

.ndp-year-item {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--ndp-text-sub);
    cursor: pointer;
    scroll-snap-align: center;
    transition: all 0.25s var(--ndp-anim);
}

.ndp-year-item:hover {
    color: var(--ndp-text-main);
}

.ndp-year-item.selected {
    font-size: 20px;
    font-weight: 700;
    color: var(--ndp-text-main);
    transform: scale(1.05);
}

.ndp-month-list {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    padding: 20px 16px;
    align-content: center;
    overscroll-behavior: contain;
}

.ndp-month-item {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--ndp-text-main);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.ndp-month-item:hover:not(.selected):not(.disabled) {
    background: var(--ndp-hover);
}

.ndp-month-item.selected {
    background: var(--ndp-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.2);
}

.ndp-month-item.disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* --- 底部 --- */
.ndp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ndp-footer-left {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ndp-btn-text {
    background: transparent;
    border: none;
    color: var(--ndp-text-sub);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 12px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-radius: 8px;
}

.ndp-btn-text:hover {
    color: var(--ndp-text-main);
    background: var(--ndp-hover);
}

.ndp-btn-text.link {
    color: var(--ndp-accent);
}

.ndp-btn-text.link:hover {
    background: var(--ndp-accent-bg);
}

.ndp-btn-text.now-btn {
    color: var(--ndp-accent);
    font-weight: 600;
}

.ndp-btn-text.now-btn:hover {
    background: var(--ndp-accent-bg);
}

.ndp-btn-text.clear-btn:hover {
    color: #ff3b30;
    background: rgba(255, 59, 48, 0.08);
}

.ndp-btn-confirm {
    background: var(--ndp-text-main);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
}

.ndp-btn-confirm:hover {
    background: #000;
}

.ndp-btn-confirm:active {
    transform: scale(0.97);
}
