/* Safari Mobile Fixes - Apply site-wide */

/* Enhanced Safari date input fix - match form-control exactly */
input[type="date"], input[type="datetime-local"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 16px !important;
}

/* Date input base styles - Dark mode */
input[type="date"].form-control, input[type="datetime-local"].form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--input-color, #ffffff);
    background-color: var(--input-bg, #27293d);
    background-clip: padding-box;
    border: 1px solid var(--input-border, #e3e3e3);
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    cursor: text;
}

/* Light mode (white-content class) */
.white-content input[type="date"].form-control, 
.white-content input[type="datetime-local"].form-control {
    color: var(--light-input-fg, #525f7f);
    background-color: #fff;
    border-color: var(--light-input-border, #e3e3e3);
}

/* Focus states - Dark mode */
input[type="date"].form-control:focus, input[type="datetime-local"].form-control:focus {
    color: #ffffff;
    background-color: var(--input-focus-bg, #27293d);
    border-color: #8898aa;
    outline: 0;
    box-shadow: 0 1px 3px rgba(50, 50, 93, 0.15), 0 1px 0 rgba(0, 0, 0, 0.02);
}

.white-content input[type="date"].form-control:focus, 
.white-content input[type="datetime-local"].form-control:focus {
    color: var(--light-input-fg, #525f7f);
    background-color: var(--light-input-focus-bg, #fff);
    border-color: var(--light-input-border, #8898aa);
}

.white-content input[type="date"]::-webkit-calendar-picker-indicator,
.white-content input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* Show native calendar picker */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    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='%23212529' d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM2 2a1 1 0 0 0-1 1v1h14V3a1 1 0 0 0-1-1H2zm13 3H1v9a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V5z'/%3e%3c/svg%3e");
    background-size: 16px 16px;
    background-repeat: no-repeat;
    background-position: center;
    width: 20px;
    height: 20px;
}

/* Focus states */
input[type="date"]:focus, input[type="datetime-local"]:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Invalid states */
input[type="date"]:invalid, input[type="datetime-local"]:invalid {
    border-color: #dc3545;
}

/* Date reset button styling */
.date-reset-btn {
    border: 1px solid #6c757d;
    color: #6c757d;
    background: transparent;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.date-reset-btn:hover {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
}

/* Input group with date reset */
.input-group .date-reset-btn {
    border-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}


/* Fix Safari zoom on input focus */
input[type="text"], input[type="email"], input[type="password"], 
input[type="number"], input[type="tel"], textarea, select {
    font-size: 16px !important;
}

/* Safari button fixes */
button, input[type="submit"], input[type="button"] {
    -webkit-appearance: none;
    border-radius: 0.25rem;
}

/* Safari select dropdown fix */
select {
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 8px 10px;
    padding-right: 2.25rem;
}

/* Safari modal scrolling fix */
@supports (-webkit-touch-callout: none) {
    .modal {
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-body {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
        max-height: calc(100vh - 200px);
    }
}

/* Fix Safari sticky positioning */
.sticky-top {
    position: -webkit-sticky;
    position: sticky;
}

/* Mobile modal adjustments */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin-top: 10px !important;
        margin-bottom: 10px !important;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
}