/* JD3 Date Picker Styles */

/* Prevent body scroll when date picker is open */
body.datepicker-open {
    overflow: hidden;
}

/* Deadline button with date */
.header-right .save-btn.has-date {
    background: #00ff00;
    color: #000;
    font-weight: 700;
}

.header-right .save-btn.has-date:hover {
    background: #00e600;
}

.header-right .save-btn.has-date-early {
    background: #ff0000;
    color: #fff;
    font-weight: 700;
}

.header-right .save-btn.has-date-early:hover {
    background: #e60000;
}

.header-right .save-btn.has-date-good {
    background: #00ff00;
    color: #000;
    font-weight: 700;
}

.header-right .save-btn.has-date-good:hover {
    background: #00e600;
}

/* Date Picker Container */
.jd3-datepicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.jd3-datepicker.active {
    opacity: 1;
    visibility: visible;
}

.datepicker-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.datepicker-container {
    position: relative;
    background: #1a1a1a;
    border-radius: 16px;
    border: 1px solid #333;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    width: 90%;
    max-width: 380px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Header */
.datepicker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #2a2a2a;
    border-bottom: 1px solid #333;
}

.month-year-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.month-year-btn:hover {
    background: #ff00ff;
    color: #fff;
}

.close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #333;
    color: #fff;
}

/* Calendar Navigation */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #333;
}

.nav-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: #333;
}

.nav-title {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
}

/* Calendar Grid */
.calendar-grid {
    padding: 20px;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 12px;
}

.weekdays div {
    text-align: center;
    font-size: 0.85rem;
    color: #999;
    font-weight: 600;
    padding: 8px 4px;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.day:not(.empty):not(.disabled):hover {
    background: #333;
}

.day.empty {
    cursor: default;
}

.day.disabled {
    color: #666;
    cursor: not-allowed;
}

.day.today {
    background: #ff00ff;
    color: #fff;
    font-weight: 700;
}

.day.selected {
    background: #ff0000;
    color: #fff;
    font-weight: 700;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.day.today.selected {
    background: #ff0000;
    color: #fff;
}

.day.production-range {
    background: var(--jd3-purple, #5E3099) !important;
    color: #fff !important;
    font-weight: 600;
    position: relative;
}

.day.production-start {
    background: var(--jd3-purple, #5E3099) !important;
    color: #fff !important;
    font-weight: 700 !important;
    position: relative;
    border: 2px solid #fff !important;
    box-sizing: border-box;
}

.day.production-end {
    background: var(--jd3-purple, #5E3099) !important;
    color: #fff !important;
    font-weight: 700 !important;
    position: relative;
    border: 2px solid #fff !important;
    box-sizing: border-box;
}

.day.delivery-range {
    background: #ffff00;
    color: #cc0000;
    font-weight: 600;
    position: relative;
}

.day.delivery-start {
    background: #ffff00;
    color: #cc0000;
    font-weight: 700;
    position: relative;
    border: 2px solid #cc0000;
    box-sizing: border-box;
}

.day.delivery-end {
    background: #ffff00;
    color: #cc0000;
    font-weight: 700;
    position: relative;
    border: 2px solid #cc0000;
    box-sizing: border-box;
}

/* Legend */
.date-legend {
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid #333;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #ccc;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-color.production {
    background: var(--jd3-purple, #5E3099);
    color: #fff;
}

.legend-color.despatch,
.legend-color.delivery {
    background: #ffff00;
    color: #cc0000;
}

.legend-color.deadline {
    background: #ff0000;
    color: #ffcccc;
}

.legend-color svg {
    width: 12px;
    height: 12px;
}

/* Warning Message */
.deadline-warning {
    margin: 0 20px;
    padding: 12px 16px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 20px;
}

.warning-content {
    color: #ff4444;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.4;
}

.warning-content strong {
    color: #cc0000;
}

/* Month and Year Views */
.month-grid,
.year-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px;
}

.month-item,
.year-item {
    padding: 16px 12px;
    text-align: center;
    background: #2a2a2a;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.month-item:hover,
.year-item:hover {
    background: #333;
}

.month-item.current,
.year-item.current {
    background: #ff00ff;
    color: #fff;
}

/* Actions */
.datepicker-actions {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #333;
}

.action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn,
.remove-btn {
    background: #333;
    color: #fff;
}

.cancel-btn:hover,
.remove-btn:hover {
    background: #444;
}

.confirm-btn {
    background: var(--jd3-purple);
    ;
    color: #fff;
}

.confirm-btn:hover:not(:disabled) {
    background: #e600e6;
}

.confirm-btn:disabled {
    background: #666;
    color: #999;
    cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .datepicker-container {
        width: 95%;
        max-width: none;
    }

    .datepicker-header {
        padding: 12px 16px;
    }

    .month-year-btn {
        font-size: 1rem;
    }

    .calendar-nav {
        padding: 12px 16px;
    }

    .calendar-grid {
        padding: 16px;
    }

    .weekdays div {
        font-size: 0.8rem;
        padding: 6px 2px;
    }

    .day {
        font-size: 0.85rem;
    }

    .month-grid,
    .year-grid {
        padding: 16px;
        gap: 8px;
    }

    .month-item,
    .year-item {
        padding: 12px 8px;
        font-size: 0.9rem;
    }

    .datepicker-actions {
        padding: 16px;
        gap: 8px;
    }

    .action-btn {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .date-legend {
        padding: 12px 16px;
        gap: 8px;
        flex-direction: column;
        align-items: center;
    }

    .legend-item {
        font-size: 0.8rem;
        gap: 6px;
        justify-content: center;
        text-align: center;
    }

    .legend-color {
        width: 18px;
        height: 18px;
    }

    .legend-color svg {
        width: 10px;
        height: 10px;
    }

    .deadline-warning {
        margin: 0 16px 16px;
        padding: 10px 12px;
    }

    .warning-content {
        font-size: 0.85rem;
    }
}

/* Dark theme compatibility */
@media (prefers-color-scheme: dark) {
    .datepicker-container {
        background: #1a1a1a;
        border-color: #333;
    }
}

/* Hidden utility */
.datepicker-view.hidden {
    display: none;
}