/* Safari-Specific Compatibility Fixes */

/* Safari backdrop-filter fallback */
@supports not (backdrop-filter: blur(10px)) {
    .service-card-front,
    .plan,
    .feature-card,
    .details-card,
    .step {
        background: rgba(255, 255, 255, 0.15) !important;
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
    }
    
    .hero-badge {
        background: rgba(212, 175, 55, 0.2) !important;
    }
}

/* Safari flexbox gap fallback */
@supports not (gap: 1rem) {
    .hero-content {
        gap: 0;
    }
    
    .hero-content > * {
        margin-right: 1.5rem;
    }
    
    .hero-content > *:last-child {
        margin-right: 0;
    }
    
    .hero-buttons {
        gap: 0;
    }
    
    .hero-buttons > * {
        margin-right: 1rem;
    }
    
    .hero-buttons > *:last-child {
        margin-right: 0;
    }
    
    .plans-grid {
        gap: 0;
    }
    
    .plans-grid > * {
        margin: 0.4rem;
    }
    
    .services-grid {
        gap: 0;
    }
    
    .services-grid > * {
        margin: 1rem;
    }
}

/* Safari grid fallback for older versions */
@supports not (display: grid) {
    .services-grid,
    .plans-grid,
    .nutrition-features,
    .process-steps {
        display: -webkit-box !important;
        display: -ms-flexbox !important;
        display: flex !important;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
    }
    
    .services-grid > *,
    .plans-grid > *,
    .nutrition-features > *,
    .process-steps > * {
        -webkit-box-flex: 1;
        -webkit-flex: 1 1 300px;
        flex: 1 1 300px;
        min-width: 280px;
        max-width: 400px;
    }
}

/* Safari 3D transform fixes */
@supports not (transform-style: preserve-3d) {
    .service-card-flip {
        -webkit-transform-style: flat !important;
        transform-style: flat !important;
    }
    
    .service-card-container.flipped .service-card-front {
        opacity: 0;
        pointer-events: none;
    }
    
    .service-card-container.flipped .service-card-back {
        opacity: 1;
        pointer-events: auto;
    }
    
    .service-card-back {
        opacity: 0;
        pointer-events: none;
        -webkit-transform: none !important;
        transform: none !important;
    }
}

/* Safari text gradient fallback */
@supports not (-webkit-background-clip: text) {
    .hero-title {
        background: none !important;
        -webkit-background-clip: initial !important;
        -webkit-text-fill-color: initial !important;
        background-clip: initial !important;
        color: white !important;
        text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    }
}

/* Safari smooth scrolling fallback */
@supports not (scroll-behavior: smooth) {
    html {
        scroll-behavior: auto;
    }
}

/* Safari-specific webkit prefixes for animations */
@keyframes heroFloat {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg);
    }
    50% { 
        transform: translateY(-20px) rotate(180deg);
    }
}

@-webkit-keyframes heroFloat {
    0%, 100% { 
        -webkit-transform: translateY(0px) rotate(0deg);
        transform: translateY(0px) rotate(0deg);
    }
    50% { 
        -webkit-transform: translateY(-20px) rotate(180deg);
        transform: translateY(-20px) rotate(180deg);
    }
}

@keyframes petFloat {
    0%, 100% { 
        transform: translate(0px, 0px) rotate(0deg);
    }
    25% { 
        transform: translate(10px, -15px) rotate(5deg);
    }
    50% { 
        transform: translate(-5px, -25px) rotate(-3deg);
    }
    75% { 
        transform: translate(-15px, -10px) rotate(2deg);
    }
}

@-webkit-keyframes petFloat {
    0%, 100% { 
        -webkit-transform: translate(0px, 0px) rotate(0deg);
        transform: translate(0px, 0px) rotate(0deg);
    }
    25% { 
        -webkit-transform: translate(10px, -15px) rotate(5deg);
        transform: translate(10px, -15px) rotate(5deg);
    }
    50% { 
        -webkit-transform: translate(-5px, -25px) rotate(-3deg);
        transform: translate(-5px, -25px) rotate(-3deg);
    }
    75% { 
        -webkit-transform: translate(-15px, -10px) rotate(2deg);
        transform: translate(-15px, -10px) rotate(2deg);
    }
}

@keyframes float {
    0%, 100% { 
        transform: translateY(0px);
    }
    50% { 
        transform: translateY(-10px);
    }
}

@-webkit-keyframes float {
    0%, 100% { 
        -webkit-transform: translateY(0px);
        transform: translateY(0px);
    }
    50% { 
        -webkit-transform: translateY(-10px);
        transform: translateY(-10px);
    }
}

@keyframes heroImageReveal {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@-webkit-keyframes heroImageReveal {
    0% {
        opacity: 0;
        -webkit-transform: translateY(50px) scale(0.8);
        transform: translateY(50px) scale(0.8);
    }
    100% {
        opacity: 1;
        -webkit-transform: translateY(0) scale(1);
        transform: translateY(0) scale(1);
    }
}

/* Safari-specific CSS classes applied by JavaScript */

/* Safari backdrop-filter fallback */
.safari-backdrop-fallback {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

.safari-backdrop-fallback.hero-badge {
    background: rgba(212, 175, 55, 0.2) !important;
}

/* Safari flexbox gap fallback */
.safari-flex-gap-fix {
    gap: 0 !important;
}

.safari-flex-gap-fix > * {
    margin: 0.5rem;
}

.safari-flex-gap-fix.hero-content > * {
    margin-right: 1.5rem;
}

.safari-flex-gap-fix.hero-content > *:last-child {
    margin-right: 0;
}

.safari-flex-gap-fix.hero-buttons > * {
    margin-right: 1rem;
}

.safari-flex-gap-fix.hero-buttons > *:last-child {
    margin-right: 0;
}

/* Safari grid fallback */
.safari-grid-fallback {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
}

.safari-grid-fallback > * {
    flex: 1 1 300px;
    min-width: 280px;
    max-width: 400px;
    margin: 0.5rem;
}

/* Safari-specific browser detection classes */
.safari .floating-pet {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.safari .service-card-flip {
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.safari-old .service-card-container {
    /* Fallback for older Safari versions */
    overflow: hidden;
}

.safari-old .service-card-back {
    /* Simplified animation for older Safari */
    transition: opacity 0.3s ease;
}

.safari-old .service-card-container.flipped .service-card-front {
    opacity: 0;
}

.safari-old .service-card-container.flipped .service-card-back {
    opacity: 1;
}

/* Safari mobile-specific fixes */
.safari.mobile .floating-pet {
    display: none !important;
}

.safari.mobile .hero-content {
    flex-direction: column;
}

.safari.mobile .hero-buttons {
    flex-direction: column;
    width: 100%;
}

.safari.mobile .hero-buttons .btn {
    width: 100%;
    margin-bottom: 1rem;
}

/* Safari-specific fixes for form elements */
input, textarea, select {
    appearance: none;
    -webkit-appearance: none;
    border-radius: 0;
    -webkit-border-radius: 0;
}

/* Safari-specific button fixes */
button, .btn {
    appearance: none;
    -webkit-appearance: none;
    border-radius: 0;
    -webkit-border-radius: 0;
    cursor: pointer;
}

/* Safari-specific image rendering */
img {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Safari-specific scroll fixes */
body {
    -webkit-overflow-scrolling: touch;
}

/* Safari-specific font rendering */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Safari-specific flexbox fixes */
.hero-content,
.hero-buttons,
.plan-header,
.plan-details,
.meal-info {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

/* Safari-specific transform fixes for better performance */
.service-card-container,
.hero-image-container,
.floating-pet,
.gold-coin {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Safari-specific media query for older versions */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .service-card-flip {
        transform-style: preserve-3d;
        -webkit-transform-style: preserve-3d;
    }
    
    .service-card-front,
    .service-card-back {
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
}

/* Safari mobile-specific fixes */
@media screen and (max-width: 768px) {
    .floating-pet {
        display: none !important;
    }
    
    .hero-content {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        flex-direction: column;
    }
    
    .hero-buttons {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        flex-direction: column;
    }
}

/* Safari-specific fixes for older versions (iOS 9-11) */
@supports (-webkit-appearance: none) and (not (display: grid)) {
    .services-grid,
    .plans-grid {
        display: -webkit-box !important;
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -webkit-flex-direction: row;
        flex-direction: row;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
    }
}

/* Safari-specific fixes for white background issues */

/* Fix grooming section boxes appearing white in Safari */
.safari .grooming-features-card,
.safari .grooming-pricing-card {
    background: rgba(0, 0, 0, 0.7) !important;
    border: 2px solid rgba(212, 175, 55, 0.3) !important;
}

.safari .feature-item {
    background: rgba(0, 0, 0, 0.5) !important;
    border: 2px solid rgba(212, 175, 55, 0.4) !important;
}

.safari .pricing-row {
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(212, 175, 55, 0.2) !important;
    color: white !important;
}

.safari .pricing-row:hover {
    background: rgba(0, 0, 0, 0.6) !important;
    border-color: rgba(212, 175, 55, 0.5) !important;
}

/* Fix contact form inputs appearing white on white in Safari */
.safari .form-group input,
.safari .form-group select,
.safari .form-group textarea {
    background: rgba(0, 0, 0, 0.6) !important;
    border: 2px solid rgba(212, 175, 55, 0.3) !important;
    color: white !important;
    -webkit-text-fill-color: white !important;
}

.safari .form-group input:focus,
.safari .form-group select:focus,
.safari .form-group textarea:focus {
    background: rgba(0, 0, 0, 0.7) !important;
    border-color: #d4af37 !important;
    color: white !important;
    -webkit-text-fill-color: white !important;
}

.safari .form-group input::placeholder,
.safari .form-group select::placeholder,
.safari .form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.7) !important;
}

/* Fix Safari autofill styling */
.safari input:-webkit-autofill,
.safari input:-webkit-autofill:hover,
.safari input:-webkit-autofill:focus,
.safari input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgba(0, 0, 0, 0.7) inset !important;
    -webkit-text-fill-color: white !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    border: 2px solid rgba(212, 175, 55, 0.3) !important;
}

/* Additional Safari form fixes */
.safari select {
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 1rem !important;
}

/* Fix Safari text selection in forms */
.safari .form-group input::-webkit-input-placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

.safari .form-group textarea::-webkit-input-placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Safari-specific backdrop-filter fallback for forms and grooming */
@supports not (backdrop-filter: blur(10px)) {
    .safari .grooming-features-card,
    .safari .grooming-pricing-card,
    .safari .form-group input,
    .safari .form-group select,
    .safari .form-group textarea {
        background: rgba(0, 0, 0, 0.8) !important;
        border: 2px solid rgba(212, 175, 55, 0.4) !important;
    }
}
