/**
 * Advanced Services Blocks - Frontend Styles
 * Responsive & SEO Optimized
 */

/* ===========================
   Global Styles
   =========================== */

.asb-block {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
}

.asb-block * {
    box-sizing: border-box;
}

/* ===========================
   Common Block Styles
   =========================== */

.asb-block-title {
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

.asb-block-description {
    margin: 0;
    line-height: 1.6;
}

/* ===========================
   Print Styles
   =========================== */

@media print {
    .asb-contact-btn,
    .asb-video-icon,
    .asb-lightbox {
        display: none !important;
    }
    
    .asb-block {
        page-break-inside: avoid;
    }
}

/* ===========================
   Accessibility
   =========================== */

.asb-block :focus {
    outline: 2px solid #ff5e15;
    outline-offset: 2px;
}

.asb-block a:focus,
.asb-block button:focus {
    box-shadow: 0 0 0 3px rgba(255, 94, 21, 0.3);
}

/* Screen reader only */
.asb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===========================
   Performance Optimizations
   =========================== */

.asb-block img,
.asb-block video {
    will-change: transform;
}

.asb-service-card,
.asb-work-item,
.asb-review-item {
    will-change: transform, box-shadow;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .asb-block * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================
   Dark Mode Support
   =========================== */

@media (prefers-color-scheme: dark) {
    .asb-service-card,
    .asb-work-item,
    .asb-review-item {
        background-color: #1a1a1a;
        border-color: #333;
    }
    
    .asb-service-description {
        color: #ccc;
    }
    
    .asb-stat-label {
        color: #999;
    }
}

/* ===========================
   RTL Support Enhancement
   =========================== */

[dir="ltr"] .asb-block {
    direction: ltr;
    text-align: left;
}

[dir="ltr"] .asb-service-features {
    text-align: left;
}

[dir="ltr"] .asb-service-features li {
    padding-right: 0;
    padding-left: 25px;
}

[dir="ltr"] .asb-service-features li:before {
    right: auto;
    left: 0;
}

/* ===========================
   High Contrast Mode
   =========================== */

@media (prefers-contrast: high) {
    .asb-service-card,
    .asb-work-item,
    .asb-review-item {
        border: 2px solid currentColor;
    }
    
    .asb-contact-btn {
        border: 2px solid currentColor;
    }
}

/* ===========================
   Loading States
   =========================== */

.asb-block img[loading="lazy"],
.asb-block video[preload="none"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: asbLoading 1.5s ease-in-out infinite;
}

@keyframes asbLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===========================
   Container Queries (Modern Browsers)
   =========================== */

@supports (container-type: inline-size) {
    .asb-services-container,
    .asb-works-container,
    .asb-reviews-container {
        container-type: inline-size;
    }
    
    @container (max-width: 768px) {
        .asb-services-grid,
        .asb-works-grid,
        .asb-reviews-grid {
            grid-template-columns: 1fr !important;
        }
    }
}

/* ===========================
   Responsive Images
   =========================== */

.asb-block img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===========================
   Extra Small Devices (< 400px)
   =========================== */

@media (max-width: 399px) {
    .asb-block-title {
        font-size: 24px !important;
    }
    
    .asb-block-description {
        font-size: 14px !important;
    }
    
    .asb-services-header,
    .asb-works-header,
    .asb-reviews-header {
        padding: 20px 15px !important;
    }
    
    .asb-service-card {
        padding: 15px !important;
    }
    
    .asb-service-icon {
        font-size: 36px !important;
    }
    
    .asb-service-title {
        font-size: 18px !important;
    }
    
    .asb-contact-btn {
        padding: 10px 20px !important;
        font-size: 16px !important;
    }
    
    .asb-stat-number {
        font-size: 28px !important;
    }
}

/* ===========================
   Hover Effects (Desktop Only)
   =========================== */

@media (hover: hover) and (pointer: fine) {
    .asb-service-card:hover {
        cursor: pointer;
    }
    
    .asb-work-item:hover .asb-work-overlay,
    .asb-review-item:hover .asb-review-overlay {
        transform: translateY(0);
    }
}

/* ===========================
   Touch Device Optimizations
   =========================== */

@media (hover: none) and (pointer: coarse) {
    .asb-service-card,
    .asb-work-item,
    .asb-review-item {
        -webkit-tap-highlight-color: rgba(255, 94, 21, 0.1);
    }
    
    .asb-contact-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Always show overlays on touch devices */
    .asb-work-overlay,
    .asb-review-overlay {
        transform: translateY(0);
        background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    }
}

/* ===========================
   Landscape Mobile Optimization
   =========================== */

@media (max-width: 896px) and (orientation: landscape) {
    .asb-services-header,
    .asb-works-header,
    .asb-reviews-header {
        padding: 15px !important;
    }
    
    .asb-block-title {
        font-size: 24px !important;
    }
    
    .asb-work-item,
    .asb-review-item {
        height: 200px !important;
    }
}

/* ===========================
   Tablet Specific (768px - 1024px)
   =========================== */

@media (min-width: 768px) and (max-width: 1024px) {
    .asb-services-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .asb-works-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .asb-reviews-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===========================
   Large Screens (> 1400px)
   =========================== */

@media (min-width: 1400px) {
    .asb-services-container,
    .asb-works-container,
    .asb-reviews-container {
        max-width: 1400px;
    }
    
    .asb-services-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
}

/* ===========================
   Safari Specific Fixes
   =========================== */

@supports (-webkit-appearance: none) {
    .asb-service-card,
    .asb-work-item,
    .asb-review-item {
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
    }
}

/* ===========================
   Firefox Specific Fixes
   =========================== */

@-moz-document url-prefix() {
    .asb-work-item video,
    .asb-review-item img {
        image-rendering: -moz-crisp-edges;
    }
}

/* ===========================
   IE11 Fallbacks (if needed)
   =========================== */

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .asb-services-grid,
    .asb-works-grid,
    .asb-reviews-grid {
        display: -ms-flexbox;
        -ms-flex-wrap: wrap;
    }
    
    .asb-service-card,
    .asb-work-item,
    .asb-review-item {
        -ms-flex: 0 0 calc(33.333% - 20px);
    }
}

/* ===========================
   Loading Animation
   =========================== */

.asb-block.asb-loading {
    opacity: 0.5;
    pointer-events: none;
}

.asb-block.asb-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff5e15;
    border-radius: 50%;
    animation: asbSpin 1s linear infinite;
}

@keyframes asbSpin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===========================
   Error States
   =========================== */

.asb-block-error {
    background: #fee;
    border: 2px solid #fcc;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
    color: #c33;
}

/* ===========================
   Smooth Scrolling
   =========================== */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ===========================
   Video Specific
   =========================== */

video::-webkit-media-controls {
    direction: ltr;
}

video::-webkit-media-controls-panel {
    direction: ltr;
}

/* ===========================
   Utility Classes
   =========================== */

.asb-mb-0 { margin-bottom: 0 !important; }
.asb-mt-0 { margin-top: 0 !important; }
.asb-p-0 { padding: 0 !important; }
.asb-hidden { display: none !important; }
.asb-visible { display: block !important; }

/* ===========================
   No JS Fallback
   =========================== */

.no-js .asb-tab-content {
    display: block !important;
}

.no-js .asb-lightbox {
    position: static !important;
    background: transparent !important;
}
