/**
 * WP Advanced Form - Date Picker Styles
 * Custom styles for jQuery UI Datepicker with Japanese locale
 * 
 * @package WP_Advanced_Form
 * @since 2.0.0
 */

/* ============================================
   Date/Time Input Wrappers
   ============================================ */

.wpaf-datetime-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wpaf-datetime-date,
.wpaf-datetime-time {
    flex: 1;
    min-width: 150px;
}

/* ============================================
   Date Input Field Styling
   ============================================ */

.wpaf-date-display,
.wpaf-month-display {
    cursor: pointer;
    background-color: #fff;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="%23666" d="M11 3c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1s-1 .4-1 1v1c0 .6.4 1 1 1zM5 3c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1S4 .4 4 1v1c0 .6.4 1 1 1zm8 1H3c-.6 0-1 .4-1 1v9c0 .6.4 1 1 1h10c.6 0 1-.4 1-1V5c0-.6-.4-1-1-1zm-1 9H4V6h8v7z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px !important;
}

.wpaf-date-display:focus,
.wpaf-month-display:focus {
    outline: 2px solid #2271b1;
    outline-offset: 0;
}

/* Hidden ISO value inputs */
.wpaf-date-iso-value,
.wpaf-datetime-iso-value,
.wpaf-month-iso-value {
    display: none !important;
}

/* ============================================
   jQuery UI Datepicker Customization
   ============================================ */

.ui-datepicker {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
    font-size: 14px;
    padding: 0;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 9999 !important;
    background: #fff;
    overflow: visible;
    width: 340px !important;
    min-width: 340px;
}

.ui-datepicker-header {
    background: linear-gradient(135deg, #2271b1 0%, #1a5a8a 100%);
    color: #fff;
    border-radius: 0;
    padding: 16px 12px;
    margin: 0;
    position: relative;
}

.ui-datepicker-title {
    color: #fff;
    font-weight: 600;
    text-align: center;
    line-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 15px;
}

/* Navigation Arrows */
.ui-datepicker-prev,
.ui-datepicker-next {
    cursor: pointer;
    width: 32px;
    height: 32px;
    top: 14px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ui-datepicker-prev {
    left: 8px;
}

.ui-datepicker-next {
    right: 8px;
}

.ui-datepicker-prev:hover,
.ui-datepicker-next:hover {
    background: rgba(255,255,255,0.2);
}

.ui-datepicker-prev:active,
.ui-datepicker-next:active {
    background: rgba(255,255,255,0.3);
}

/* Disabled navigation */
.ui-datepicker-prev.ui-state-disabled,
.ui-datepicker-next.ui-state-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ui-datepicker-prev.ui-state-disabled:hover,
.ui-datepicker-next.ui-state-disabled:hover {
    background: transparent;
}

/* Arrow icons */
.ui-datepicker-prev span,
.ui-datepicker-next span {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
}

.ui-icon-circle-triangle-w:before {
    content: '◀';
}

.ui-icon-circle-triangle-e:before {
    content: '▶';
}

/* Calendar Table */
.ui-datepicker-calendar {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 2px;
    padding: 8px;
    background: #fff;
}

/* Day headers (日月火水木金土) */
.ui-datepicker-calendar th {
    padding: 10px 4px;
    text-align: center;
    font-weight: 700;
    color: #555;
    font-size: 13px;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Sunday header */
.ui-datepicker-calendar th:first-child {
    color: #e53935;
}

/* Saturday header */
.ui-datepicker-calendar th:last-child {
    color: #1e88e5;
}

/* Calendar cells */
.ui-datepicker-calendar td {
    padding: 2px;
    text-align: center;
}

/* Date numbers */
.ui-datepicker-calendar td span,
.ui-datepicker-calendar td a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    text-align: center;
    text-decoration: none;
    color: #333;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
}

/* Hover effect */
.ui-datepicker-calendar td a:hover {
    background: #e3f2fd;
    color: #1976d2;
    transform: scale(1.05);
}

/* Today */
.ui-datepicker-calendar td.ui-datepicker-today a {
    background: #fff3e0;
    color: #f57c00;
    font-weight: 700;
    border: 2px solid #ff9800;
}

.ui-datepicker-calendar td.ui-datepicker-today a:hover {
    background: #ffe0b2;
    transform: scale(1.05);
}

/* Selected day */
.ui-datepicker-calendar td.ui-datepicker-current-day a {
    background: linear-gradient(135deg, #2271b1 0%, #1a5a8a 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.3);
}

.ui-datepicker-calendar td.ui-datepicker-current-day a:hover {
    background: linear-gradient(135deg, #1a5a8a 0%, #135e96 100%);
    transform: scale(1.05);
}

/* Disabled/unselectable days */
.ui-datepicker-calendar td.ui-datepicker-unselectable span,
.ui-datepicker-calendar td.ui-datepicker-other-month {
    color: #ccc;
    cursor: not-allowed;
}

/* Weekend days (Sunday = red, Saturday = blue) */
.ui-datepicker-calendar td.ui-datepicker-week-end:first-child a {
    color: #e53935; /* Sunday red */
}

.ui-datepicker-calendar td.ui-datepicker-week-end:last-child a {
    color: #1e88e5; /* Saturday blue */
}

/* Weekend selected days */
.ui-datepicker-calendar td.ui-datepicker-week-end.ui-datepicker-current-day a {
    color: #fff; /* Override weekend color when selected */
}

/* ============================================
   Month & Year Dropdowns (2025年 10月 style)
   ============================================ */

.ui-datepicker-year {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: rgba(255,255,255,0.15);
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23ffffff" d="M6 8L0 2l1.41-1.41L6 5.17l4.59-4.58L12 2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    padding: 6px 32px 6px 12px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    min-width: 85px;
    transition: all 0.2s ease;
    text-align: center;
}

.ui-datepicker-month {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: rgba(255,255,255,0.15);
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23ffffff" d="M6 8L0 2l1.41-1.41L6 5.17l4.59-4.58L12 2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    padding: 6px 32px 6px 12px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    min-width: 75px;
    transition: all 0.2s ease;
    text-align: center;
}

.ui-datepicker-year:hover,
.ui-datepicker-month:hover {
    background-color: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.ui-datepicker-year:focus,
.ui-datepicker-month:focus {
    outline: none;
    background-color: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.7);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}

.ui-datepicker-year:active,
.ui-datepicker-month:active {
    transform: translateY(0);
}

/* ============================================
   Custom Time Picker (24-hour format)
   ============================================ */

.wpaf-time-picker-container {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.wpaf-time-hour,
.wpaf-time-minute {
    font-size: 15px;
    font-weight: 500;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", sans-serif;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23666" d="M6 8L0 2l1.41-1.41L6 5.17l4.59-4.58L12 2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
    padding-right: 28px;
}

.wpaf-time-hour:hover,
.wpaf-time-minute:hover {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.05);
}

.wpaf-time-hour:focus,
.wpaf-time-minute:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.wpaf-time-picker-container span {
    font-size: 18px;
    font-weight: bold;
    color: #666;
    user-select: none;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .wpaf-datetime-wrapper {
        flex-direction: column;
    }
    
    .wpaf-datetime-date,
    .wpaf-datetime-time {
        width: 100% !important;
        min-width: auto;
    }
    
    .ui-datepicker {
        width: 100% !important;
        max-width: 360px;
        min-width: 320px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ui-datepicker-header {
        padding: 14px 10px;
    }
    
    .ui-datepicker-calendar td span,
    .ui-datepicker-calendar td a {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    
    .ui-datepicker-month,
    .ui-datepicker-year {
        font-size: 14px;
        padding: 5px 28px 5px 10px;
        min-width: 75px;
    }
    
    .ui-datepicker-prev,
    .ui-datepicker-next {
        width: 36px;
        height: 36px;
        top: 12px;
    }
}

/* Tablet size */
@media (min-width: 769px) and (max-width: 1024px) {
    .ui-datepicker {
        width: 360px !important;
        min-width: 360px;
    }
}

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .wpaf-date-display,
    .wpaf-month-display {
        background-color: #1e1e1e;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }
    
    .ui-datepicker {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }
    
    .ui-datepicker-header {
        background: #135e96;
    }
    
    .ui-datepicker-calendar th {
        color: #b0b0b0;
    }
    
    .ui-datepicker-calendar td span,
    .ui-datepicker-calendar td a {
        color: #e0e0e0;
    }
    
    .ui-datepicker-calendar td a:hover {
        background: #3a3a3a;
    }
    
    .ui-datepicker-calendar td.ui-datepicker-today a {
        background: #1e4d6b;
    }
    
    .ui-datepicker-month,
    .ui-datepicker-year {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }
}

/* ============================================
   Accessibility
   ============================================ */

.ui-datepicker:focus-within {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.ui-datepicker-calendar td a:focus {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px #fff;
}

/* ============================================
   Animation
   ============================================ */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ui-datepicker {
    animation: fadeInDown 0.2s ease-out;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .ui-datepicker {
        animation: none;
    }
    
    .ui-datepicker-calendar td span,
    .ui-datepicker-calendar td a {
        transition: none;
    }
}

