/**
 * Due Date Calculator Styles (Redesign A)
 * 출산 예정일 계산기 전면 리디자인 + 모바일 date input overflow 가드
 *
 * @package Zipper
 */

#dueDateCalculator {
    --duedate-accent: #d4af37;
    --duedate-accent-dark: #b8860b;
    --duedate-border: #e8e4dc;
    --duedate-bg-soft: #faf9f7;
    --duedate-text-main: #2d2a26;
    --duedate-text-sub: #5f5a56;
    --duedate-text-muted: #8b7355;
    overflow-x: hidden;
}

#dueDateCalculator .tool-layout-split {
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 20px;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

#dueDateCalculator .tool-input-panel,
#dueDateCalculator .tool-result-panel,
#dueDateCalculator .duedate-input-section,
#dueDateCalculator .duedate-result-section,
#dueDateCalculator .duedate-input-group,
#dueDateCalculator .cycle-input-wrapper {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#dueDateCalculator .tool-input-panel {
    position: sticky;
    top: 100px;
    width: 100%;
    max-width: 100%;
    align-self: start;
    overflow-x: clip;
}

#dueDateCalculator .tool-result-panel {
    position: static;
    width: 100%;
    max-width: 100%;
}

/* 입력 영역 */
.duedate-input-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--duedate-border);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(45, 42, 38, 0.06);
    overflow: hidden;
}

.duedate-input-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.duedate-input-title {
    margin: 0;
    font-size: 17px;
    line-height: 1.4;
    color: var(--duedate-text-main);
}

.duedate-input-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--duedate-text-sub);
    line-height: 1.55;
}

.duedate-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duedate-input-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--duedate-text-main);
}

.duedate-date-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--duedate-border);
    border-radius: 10px;
    background: #fff;
    box-sizing: border-box;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.duedate-date-wrap:hover {
    border-color: #d4c67a;
}

.duedate-date-wrap:focus-within {
    border-color: var(--duedate-accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.duedate-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid var(--duedate-border);
    border-radius: 10px;
    background: #fff;
    color: var(--duedate-text-main);
    font-size: 16px;
    line-height: 1.3;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.duedate-input:hover {
    border-color: #d4c67a;
}

.duedate-input:focus {
    outline: none;
    border-color: var(--duedate-accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

/* 모바일 달력 입력 안정화 핵심 가드 */
.duedate-date-wrap .duedate-input[type="date"] {
    inline-size: 100%;
    width: 100%;
    max-inline-size: 100%;
    max-width: 100%;
    min-inline-size: 0;
    min-width: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none !important;
    padding: 12px 10px 12px 12px;
    background: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.01em;
    font-size: 16px !important;
    -webkit-min-logical-width: 0;
}

.duedate-date-wrap .duedate-input[type="date"]::-webkit-datetime-edit,
.duedate-date-wrap .duedate-input[type="date"]::-webkit-date-and-time-value,
.duedate-date-wrap .duedate-input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duedate-date-wrap .duedate-input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1;
    margin: 0;
    padding: 0;
}

.cycle-input-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 120px) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
}

.cycle-input-wrapper .duedate-input {
    text-align: center;
}

.cycle-hint {
    font-size: 13px;
    color: var(--duedate-text-muted);
    line-height: 1.45;
}

.duedate-tips {
    margin: 0;
    padding: 10px 12px;
    list-style: none;
    border: 1px solid var(--duedate-border);
    border-radius: 10px;
    background: var(--duedate-bg-soft);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.duedate-tips li {
    position: relative;
    padding-left: 14px;
    font-size: 13px;
    color: var(--duedate-text-sub);
    line-height: 1.5;
}

.duedate-tips li::before {
    content: '•';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--duedate-accent);
    font-weight: 700;
}

/* 결과 영역 */
.duedate-result-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.duedate-main-result {
    background: linear-gradient(135deg, #fdfbf5 0%, #faf6ec 100%);
    border: 2px solid var(--duedate-accent);
    border-radius: 14px;
    padding: 26px 20px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(212, 175, 55, 0.12);
}

.duedate-label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--duedate-text-muted);
    letter-spacing: 0.01em;
}

.duedate-value {
    font-size: clamp(26px, 4vw, 34px);
    font-weight: 700;
    line-height: 1.35;
    color: var(--duedate-accent-dark);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.duedate-weekday {
    font-size: 15px;
    color: var(--duedate-text-sub);
    margin-bottom: 12px;
}

.duedate-dday {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--duedate-accent) 0%, var(--duedate-accent-dark) 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.duedate-dday:empty {
    display: none;
}

.duedate-current-week,
.duedate-timeline,
.duedate-key-dates {
    background: #fff;
    border: 1px solid var(--duedate-border);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(45, 42, 38, 0.06);
}

.duedate-current-week {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
}

.current-week-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--duedate-accent) 0%, var(--duedate-accent-dark) 100%);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.current-week-info {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: var(--duedate-text-main);
    line-height: 1.55;
}

.current-week-info strong {
    color: var(--duedate-accent-dark);
}

.duedate-timeline {
    padding: 16px;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--duedate-text-main);
}

.timeline-bar {
    position: relative;
    height: 12px;
    border-radius: 999px;
    background: #ece7dd;
    overflow: hidden;
    margin-bottom: 12px;
}

.timeline-progress {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #f0ce70 0%, var(--duedate-accent) 55%, var(--duedate-accent-dark) 100%);
    transition: width 0.5s ease;
}

.timeline-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid var(--duedate-accent);
    background: #fff;
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.3);
    z-index: 2;
    transition: left 0.5s ease;
}

.timeline-labels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.timeline-period {
    padding: 8px;
    text-align: center;
    border: 1px solid var(--duedate-border);
    border-radius: 8px;
    background: #fff;
}

.timeline-period.first {
    background: rgba(245, 197, 66, 0.08);
}

.timeline-period.second {
    background: rgba(212, 175, 55, 0.12);
}

.timeline-period.third {
    background: rgba(184, 148, 45, 0.14);
}

.period-label {
    display: block;
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 700;
    color: var(--duedate-text-main);
}

.period-weeks {
    display: block;
    font-size: 13px;
    color: var(--duedate-text-sub);
}

.duedate-key-dates {
    padding: 16px;
}

.key-dates-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--duedate-text-main);
}

.key-dates-title i {
    color: var(--duedate-accent);
}

.key-dates-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.key-date-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--duedate-border);
    border-radius: 8px;
    background: #fff;
    min-width: 0;
}

.key-date-label {
    font-size: 13px;
    line-height: 1.4;
    color: var(--duedate-text-muted);
}

.key-date-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--duedate-text-main);
}

.duedate-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.duedate-actions .tool-btn {
    width: 100%;
    justify-content: center;
    min-width: 0;
}

/* description 내부 표 가독성 보강 */
.tool-description table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.tool-description th,
.tool-description td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--duedate-border);
}

.tool-description th {
    background: var(--duedate-bg-soft);
    color: var(--duedate-text-main);
    font-weight: 600;
}

.tool-description td {
    color: var(--duedate-text-sub);
}

/* ===== 반응형 ===== */
@media (max-width: 1024px) {
    #dueDateCalculator .tool-layout-split {
        grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
        gap: 16px;
    }

    #dueDateCalculator .tool-input-panel {
        top: 92px;
    }
}

@media (max-width: 900px) {
    #dueDateCalculator .tool-layout-split {
        grid-template-columns: 1fr;
    }

    #dueDateCalculator .tool-input-panel {
        position: static;
    }

    .duedate-input-group input:not([type="radio"]):not([type="checkbox"]),
    .duedate-input-group select,
    .duedate-input-group textarea {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    .cycle-input-wrapper {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .cycle-input-wrapper .duedate-input {
        text-align: left;
    }

    .duedate-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .duedate-input-section,
    .duedate-main-result,
    .duedate-current-week,
    .duedate-timeline,
    .duedate-key-dates {
        padding: 14px;
    }

    .duedate-value {
        font-size: 24px;
    }

    .duedate-current-week {
        flex-direction: column;
        text-align: center;
    }

    .key-dates-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    #dueDateCalculator,
    #dueDateCalculator .tool-layout-split,
    #dueDateCalculator .tool-input-panel,
    #dueDateCalculator .tool-result-panel,
    #dueDateCalculator .duedate-input-section,
    #dueDateCalculator .duedate-result-section,
    #dueDateCalculator .duedate-input-group,
    #dueDateCalculator .cycle-input-wrapper {
        max-width: 100%;
        overflow-x: hidden;
    }

    .duedate-date-wrap .duedate-input[type="date"] {
        font-size: 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 12px 8px 12px 10px !important;
    }

    .duedate-value {
        font-size: 22px;
    }

    .current-week-badge {
        width: 56px;
        height: 56px;
        font-size: 18px;
    }

    .timeline-labels {
        grid-template-columns: 1fr;
    }

    .timeline-period {
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    .duedate-input,
    .timeline-progress,
    .timeline-marker,
    .tool-btn {
        transition: none !important;
    }
}
