/**
 * 中文日期 / 日期时间选择器
 * 接管原生 <input type="date|datetime-local|month|time">，统一为中文美化面板。
 * 面板挂在 body 下，绝对定位，不受弹窗 / 表格 overflow 裁剪影响。
 */

/* ---------- 输入框 ---------- */
/* 用 input.xxx 提高特异性压过各页 .f-control，避免 !important 之间的博弈 */
input.cc-dp-input {
    cursor: pointer;
    /* 右侧留出日历图标位 */
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

input.cc-dp-input.cc-dp-time-only {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");
}

input.cc-dp-input.cc-dp-open {
    border-color: var(--primary, #5e6d82);
    box-shadow: 0 0 0 3px rgba(94, 109, 130, 0.12);
}

/* ---------- 面板 ---------- */
.cc-dp-panel {
    position: absolute;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
    padding: 0;
    font-size: 13px;
    color: var(--text-main, #1d1d1f);
    user-select: none;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    /* 定位完成（加 .cc-dp-show）前不参与命中，避免点到未就位的面板 */
    pointer-events: none;
}

.cc-dp-panel.cc-dp-show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* 日历 + 时间列并排 */
.cc-dp-body {
    display: flex;
}

.cc-dp-main {
    width: 296px;
    padding: 12px 12px 0;
}

/* ---------- 头部 ---------- */
.cc-dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 10px;
}

.cc-dp-nav {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-sub, #6e6e73);
    transition: background 0.15s, color 0.15s;
}

.cc-dp-nav:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main, #1d1d1f);
}

.cc-dp-nav svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
}

.cc-dp-title {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.cc-dp-title:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ---------- 星期 ---------- */
.cc-dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 2px;
}

.cc-dp-weekdays span {
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #86868b);
    line-height: 28px;
}

.cc-dp-weekdays span:first-child,
.cc-dp-weekdays span:last-child {
    color: #c86b6b;
}

/* ---------- 日期网格 ---------- */
.cc-dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cc-dp-cell {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    position: relative;
    transition: background 0.14s, color 0.14s;
}

.cc-dp-cell:hover {
    background: rgba(94, 109, 130, 0.1);
}

.cc-dp-cell.cc-dp-muted {
    color: #c4c4c8;
}

/* 今天：底部小圆点 */
.cc-dp-cell.cc-dp-today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary, #5e6d82);
}

.cc-dp-cell.cc-dp-selected {
    background: var(--primary, #5e6d82);
    color: #fff;
    font-weight: 600;
}

.cc-dp-cell.cc-dp-selected:hover {
    background: var(--primary-hover, #4a5568);
}

.cc-dp-cell.cc-dp-selected.cc-dp-today::after {
    background: #fff;
}

.cc-dp-cell.cc-dp-disabled {
    color: #d8d8dc;
    cursor: not-allowed;
    background: transparent;
}

/* ---------- 月 / 年 视图 ---------- */
.cc-dp-grid.cc-dp-grid-my {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-top: 4px;
}

.cc-dp-grid-my .cc-dp-cell {
    height: 52px;
    border-radius: 10px;
}

/* ---------- 时间列 ---------- */
.cc-dp-time {
    width: 116px;
    border-left: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
}

.cc-dp-time-head {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub, #6e6e73);
    line-height: 38px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cc-dp-time-cols {
    flex: 1;
    display: flex;
    min-height: 0;
}

.cc-dp-time-col {
    flex: 1;
    overflow-y: auto;
    max-height: 246px;
    padding: 4px 0;
    scrollbar-width: thin;
}

.cc-dp-time-col:first-child {
    border-right: 1px solid rgba(0, 0, 0, 0.04);
}

.cc-dp-time-col::-webkit-scrollbar {
    width: 4px;
}

.cc-dp-time-col::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.cc-dp-time-item {
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    border-radius: 6px;
    margin: 1px 6px;
    transition: background 0.14s, color 0.14s;
}

.cc-dp-time-item:hover {
    background: rgba(94, 109, 130, 0.1);
}

.cc-dp-time-item.cc-dp-selected {
    background: var(--primary, #5e6d82);
    color: #fff;
    font-weight: 600;
}

/* 纯时间模式：面板只剩时间列 */
.cc-dp-panel.cc-dp-only-time .cc-dp-time {
    width: 150px;
    border-left: none;
}

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

.cc-dp-foot-left {
    display: flex;
    gap: 6px;
}

.cc-dp-btn {
    height: 30px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    color: var(--text-sub, #6e6e73);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cc-dp-btn:hover {
    border-color: var(--primary, #5e6d82);
    color: var(--primary, #5e6d82);
}

.cc-dp-btn-primary {
    background: var(--primary, #5e6d82);
    border-color: var(--primary, #5e6d82);
    color: #fff;
    font-weight: 500;
}

.cc-dp-btn-primary:hover {
    background: var(--primary-hover, #4a5568);
    border-color: var(--primary-hover, #4a5568);
    color: #fff;
}

/* 面板整体在窄屏下的收缩 */
@media (max-width: 480px) {
    .cc-dp-main { width: 260px; }
    .cc-dp-time { width: 96px; }
}
