/* ========================================
   日历选择器样式
   现代化、移动端友好的日期时间选择器
   ======================================== */

/* 日期输入框包装器 */
.datepicker-wrapper {
    position: relative;
    width: 100%;
}

.datepicker-input {
    position: relative;
}

.datepicker-input input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: var(--transition);
    cursor: pointer;
}

.datepicker-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.datepicker-input input:read-only {
    background: var(--bg-primary);
    cursor: pointer;
}

.datepicker-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 16px;
    pointer-events: none;
}

/* 日历弹出层 */
.datepicker-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1000;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 16px;
    min-width: 320px;
    animation: datepickerFadeIn 0.2s ease;
    display: none;
}

.datepicker-popup.show {
    display: block;
}

@keyframes datepickerFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 日历头部 */
.datepicker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.datepicker-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.datepicker-nav {
    display: flex;
    gap: 8px;
}

.datepicker-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.datepicker-nav-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.datepicker-nav-btn:active {
    transform: scale(0.95);
}

/* 星期标题 */
.datepicker-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.datepicker-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 8px 0;
}

/* 日期网格 */
.datepicker-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.datepicker-day {
    aspect-ratio: 1;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.datepicker-day:hover:not(.disabled):not(.other-month) {
    background: var(--bg-secondary);
}

.datepicker-day.today {
    color: var(--primary-color);
    font-weight: 600;
}

.datepicker-day.selected {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.datepicker-day.other-month {
    color: var(--text-tertiary);
    opacity: 0.4;
}

.datepicker-day.disabled {
    color: var(--text-tertiary);
    opacity: 0.3;
    cursor: not-allowed;
}

/* 时间选择器 */
.datepicker-time {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.datepicker-time-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.datepicker-time-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.datepicker-time-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.datepicker-time-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
    width: 100%;
}

.datepicker-time-separator {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* 底部按钮 */
.datepicker-footer {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.datepicker-footer .btn {
    flex: 1;
    justify-content: center;
}

/* ========================================
   移动端优化
   ======================================== */

@media (max-width: 768px) {
    .datepicker-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100% - 32px);
        max-width: 400px;
        min-width: unset;
        z-index: 10000;
    }
    
    .datepicker-popup.show {
        animation: datepickerSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes datepickerSlideUp {
        from {
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }
    
    .datepicker-input input {
        padding: 12px 40px 12px 14px;
        font-size: 16px; /* 防止iOS缩放 */
        border: 2px solid var(--border-color);
    }
    
    .datepicker-input input:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    }
    
    .datepicker-header {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }
    
    .datepicker-title {
        font-size: 18px;
    }
    
    .datepicker-nav-btn {
        width: 40px;
        height: 40px;
    }
    
    .datepicker-weekday {
        font-size: 13px;
        padding: 10px 0;
    }
    
    .datepicker-day {
        font-size: 15px;
        min-height: 44px;
    }
    
    .datepicker-time-input {
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .datepicker-time-label {
        font-size: 13px;
    }
    
    .datepicker-footer .btn {
        padding: 12px 20px;
        font-size: 15px;
        min-height: 48px;
    }
}

/* 遮罩层 */
.datepicker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    animation: fadeIn 0.2s ease;
}

.datepicker-overlay.show {
    display: block;
}

@media (max-width: 768px) {
    .datepicker-overlay {
        backdrop-filter: blur(4px);
    }
}

/* 快捷选择 */
.datepicker-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.datepicker-shortcut {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.datepicker-shortcut:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

@media (max-width: 768px) {
    .datepicker-shortcut {
        padding: 8px 14px;
        font-size: 13px;
        flex: 1;
        text-align: center;
    }
}

