/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Performance optimizations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Inter', sans-serif !important;
    line-height: 1.6;
    color: #333;
    background-color: transparent;
    /* Performance optimizations */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Force font on all elements */
* {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Inter', sans-serif !important;
}

/* Header */
.fixed-header {
    background: transparent;
    color: black;
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

.main-message {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.secondary-message {
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.9;
    max-width: 800px;
    margin: 0 auto;
}

/* Main Content */
.main-content {
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.services-section {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    padding: 2rem;
    align-items: stretch;
}

/* Service Cards */
.service-card {
    background: transparent;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: default;
    position: relative;
    width: 100%;
    height: 100%;
    /* Performance optimizations */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Show pointer cursor for contact request and deximind */
.service-card.contact-request,
.service-card.deximind-agent {
    cursor: pointer;
}

.service-card:hover {
    transform: translate3d(0, -8px, 0);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    /* Performance optimization for hover state */
    will-change: transform, box-shadow;
}

.image-container {
    position: relative;
    height: 400px;
    overflow: hidden;
    border-radius: 16px;
    width: 100%;
}

.service-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    border: none;
    display: block;
    /* Performance optimizations */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Image loading states */
.image-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.image-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.image-loading p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Lazy loading styles */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* Handle iframe placeholders */
iframe.service-image {
    border: none;
    object-fit: cover;
    width: 100%;
    height: 100%;
    display: block;
    /* Improve iframe rendering quality for JPG images */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    image-rendering: smooth;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Force hardware acceleration */
    will-change: transform;
    backface-visibility: hidden;
    /* Enhance image quality */
    -webkit-filter: contrast(1.05) brightness(1.02);
    filter: contrast(1.05) brightness(1.02);
}

/* Optimize image loading */
img.service-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    image-rendering: smooth;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Ensure DexiMind image loads immediately */
.service-card.deximind-agent img.service-image {
    opacity: 1;
    display: block;
}

/* Hide loading spinner for DexiMind image */
.service-card.deximind-agent .image-loading {
    display: none !important;
}

.service-card:hover .service-image {
    transform: scale(1.05);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transform: translateY(0);
    transition: all 0.3s ease;
    box-sizing: border-box;
    overflow: hidden;
    max-height: 100%;
}

/* Contact image text behavior */
.overlay-text-default {
    display: block;
}

.overlay-text-hover {
    display: none;
}

.service-card.contact-request:hover .overlay-text-default,
.service-card.deximind-agent:hover .overlay-text-default {
    display: none;
}

.service-card.contact-request:hover .overlay-text-hover,
.service-card.deximind-agent:hover .overlay-text-hover {
    display: block;
}

/* Keep overlay always visible but hide text by default for product development and technical assistance */
.service-card.product-development .image-overlay,
.service-card.technical-assistance .image-overlay {
    opacity: 1;
    visibility: visible;
}

/* Hide default text by default for product development and technical assistance */
.service-card.product-development .overlay-text-default,
.service-card.technical-assistance .overlay-text-default {
    display: none;
}

.service-card.product-development .overlay-text-hover,
.service-card.technical-assistance .overlay-text-hover {
    display: none;
}

/* Hide default text and show hover text on hover for product development and technical assistance (same as Image1) */
.service-card.product-development:hover .overlay-text-default,
.service-card.technical-assistance:hover .overlay-text-default {
    display: none;
}

.service-card.product-development:hover .overlay-text-hover,
.service-card.technical-assistance:hover .overlay-text-hover {
    display: block;
}

.image-overlay > * {
    max-width: 100%;
    width: 100%;
}

.service-card:hover .image-overlay {
    transform: translateY(-10px);
}

.overlay-text {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    font-weight: 600;
    display: block;
    text-align: center;
    line-height: 1.2;
    margin: 0;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Enhanced text sharpness and rendering */
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.9);
    color: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1;
}

.overlay-text p,
.overlay-text-default p,
.overlay-text-hover p {
    margin-bottom: 0.8rem;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.9);
    color: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1;
    /* Force consistent rendering */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Inter', sans-serif !important;
}

/* Specific rule to ensure Image2 and Image3 text renders as crisp as Image1 */
.service-card.product-development .overlay-text-hover p,
.service-card.technical-assistance .overlay-text-hover p {
    margin-bottom: 0.8rem !important;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem) !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.9) !important;
    color: #ffffff !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
    font-feature-settings: "kern" 1 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Inter', sans-serif !important;
}

.service-title {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.3;
    text-align: center;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Removed service-description p rule - using overlay-text-default p instead */

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background-color: transparent;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
    color: white;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: white;
    transition: color 0.2s ease;
}

.close-button:hover {
    color: #ccc;
}

.modal h2 {
    margin-bottom: 1.5rem;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Form Styles */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: white;
}

.form-group input,
.form-group textarea {
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Placeholder styles */
.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.form-group input::-webkit-input-placeholder,
.form-group textarea::-webkit-input-placeholder {
    color: #9ca3af;
    opacity: 1;
}

.form-group input::-moz-placeholder,
.form-group textarea::-moz-placeholder {
    color: #9ca3af;
    opacity: 1;
}

.form-group input:-ms-input-placeholder,
.form-group textarea:-ms-input-placeholder {
    color: #9ca3af;
    opacity: 1;
}

.submit-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.submit-button:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    /* Performance optimization */
    will-change: transform, box-shadow;
}

.submit-button:active {
    transform: translateY(0);
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 1400px) {
    .services-section {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1200px;
    }
}

@media (max-width: 1000px) {
    .services-section {
        grid-template-columns: repeat(2, 1fr);
        max-width: 800px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 0.5rem;
        min-height: auto;
    }
    
    .services-section {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem;
    }
    
    .image-container {
        height: 350px;
    }
    

    
    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
        width: 95%;
    }
    
    .image-container {
        height: 250px;
    }
    
    .image-overlay {
        padding: 1.5rem 1rem;
    }
    
    .service-title {
        font-size: clamp(1rem, 3.5vw, 1.4rem);
        margin-bottom: 0.8rem;
    }
    
    .overlay-text-default p {
        font-size: clamp(0.8rem, 2.5vw, 1rem);
        margin-bottom: 0.7rem;
    }
}

@media (max-width: 480px) {
    .services-section {
        padding: 0.5rem;
        gap: 1rem;
    }
    
    .image-container {
        height: 300px;
    }
    
    .image-overlay {
        padding: 1rem 0.8rem;
    }
    
    .service-title {
        font-size: clamp(0.9rem, 4vw, 1.2rem);
        margin-bottom: 0.6rem;
    }
    
    .overlay-text-default p {
        font-size: clamp(0.7rem, 3vw, 0.9rem);
        margin-bottom: 0.6rem;
        line-height: 1.3;
    }
}
