/**
 * WebView DateTime Picker Styles
 * ===============================
 * 
 * Mobile-optimized styles for the WebView-compatible datetime picker.
 * Designed to look native and work well on Android devices.
 */

.webview-datetime-picker {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background-color: #ffffff;
    font-size: 16px;
    min-height: 44px; /* Touch-friendly minimum height */
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.webview-datetime-picker:focus-within {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.webview-datetime-picker input[type="date"],
.webview-datetime-picker input[type="time"],
.webview-datetime-picker select.hour-select,
.webview-datetime-picker select.minute-select {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
    flex: 1;
    min-width: 0;
    color: #212529;
    font-family: inherit;
    line-height: 1.5;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

/* Custom time picker select-specific styles */
.webview-datetime-picker select.hour-select,
.webview-datetime-picker select.minute-select {
    min-width: 45px !important;
    flex: 0 0 auto !important;
    padding: 2px 20px 2px 4px !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 12px;
}

.webview-datetime-picker input[type="date"]:focus,
.webview-datetime-picker input[type="time"]:focus,
.webview-datetime-picker select.hour-select:focus,
.webview-datetime-picker select.minute-select:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background-color: rgba(13, 110, 253, 0.1) !important;
    border-radius: 3px;
}

/* Divider between date and time */
.webview-datetime-picker span {
    color: #6c757d;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
    line-height: 1;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .webview-datetime-picker {
        background-color: #2b3035;
        border-color: #495057;
        color: #ffffff;
    }
    
    .webview-datetime-picker input[type="date"],
    .webview-datetime-picker input[type="time"],
    .webview-datetime-picker select.hour-select,
    .webview-datetime-picker select.minute-select {
        color: #ffffff !important;
        background: transparent !important;
    }
    
    .webview-datetime-picker:focus-within {
        border-color: #6ea8fe;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    }
    
    .webview-datetime-picker span {
        color: #adb5bd;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .webview-datetime-picker {
        min-height: 48px; /* Larger touch target on mobile */
        padding: 12px 14px;
        font-size: 16px; /* Prevent zoom on mobile browsers */
    }
    
    .webview-datetime-picker input[type="date"],
    .webview-datetime-picker input[type="time"],
    .webview-datetime-picker select.hour-select,
    .webview-datetime-picker select.minute-select {
        font-size: 16px !important; /* Prevent zoom */
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* Android-specific enhancements */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    .webview-datetime-picker {
        /* Better touch feedback on Android */
        touch-action: manipulation;
    }
    
    .webview-datetime-picker input[type="date"],
    .webview-datetime-picker input[type="time"],
    .webview-datetime-picker select.hour-select,
    .webview-datetime-picker select.minute-select {
        /* Optimize for Android WebView */
        -webkit-tap-highlight-color: transparent;
        tap-highlight-color: transparent;
    }
}

/* High DPI displays (including Android) */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
       only screen and (min--moz-device-pixel-ratio: 2),
       only screen and (-o-min-device-pixel-ratio: 2/1),
       only screen and (min-device-pixel-ratio: 2),
       only screen and (min-resolution: 192dpi),
       only screen and (min-resolution: 2dppx) {
    
    .webview-datetime-picker {
        /* Ensure crisp borders on high-DPI displays */
        border-width: 0.5px;
    }
}

/* Focus states for accessibility */
.webview-datetime-picker input[type="date"]:focus + span + input[type="time"],
.webview-datetime-picker input[type="time"]:focus {
    /* Visual indication when nested inputs are focused */
}

/* Invalid state */
.webview-datetime-picker.is-invalid {
    border-color: #dc3545;
}

.webview-datetime-picker.is-invalid:focus-within {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

/* Disabled state */
.webview-datetime-picker.disabled {
    background-color: #e9ecef;
    opacity: 1;
    pointer-events: none;
}

.webview-datetime-picker.disabled input[type="date"],
.webview-datetime-picker.disabled input[type="time"] {
    background-color: transparent !important;
    color: #6c757d !important;
}

/* Loading state (optional) */
.webview-datetime-picker.loading {
    position: relative;
    pointer-events: none;
}

.webview-datetime-picker.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: webview-picker-spin 1s linear infinite;
}

@keyframes webview-picker-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Integration with Bootstrap form styles */
.form-floating .webview-datetime-picker {
    height: calc(3.5rem + 2px);
    line-height: 1.25;
    padding: 1rem 0.75rem 0.25rem 0.75rem;
}

.form-floating .webview-datetime-picker input[type="date"],
.form-floating .webview-datetime-picker input[type="time"] {
    padding: 0 !important;
    height: auto;
    line-height: 1.25;
}

/* Small form controls */
.form-control-sm .webview-datetime-picker,
.webview-datetime-picker.form-control-sm {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Large form controls */
.form-control-lg .webview-datetime-picker,
.webview-datetime-picker.form-control-lg {
    min-height: calc(1.5em + 1rem + 2px);
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
}

/* RTL support */
[dir="rtl"] .webview-datetime-picker {
    flex-direction: row-reverse;
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
    .webview-datetime-picker {
        transition: none;
    }
    
    .webview-datetime-picker.loading::after {
        animation: none;
    }
}

/* Print styles */
@media print {
    .webview-datetime-picker {
        border: 1px solid #000;
        background: white !important;
        color: black !important;
    }
    
    .webview-datetime-picker input[type="date"],
    .webview-datetime-picker input[type="time"] {
        color: black !important;
    }
} 