/* ========================================
   ENHANCED RESPONSIVE DESIGN
   للهواتف والأجهزة اللوحية وجميع الأجهزة
   ======================================== */

/* ===== Viewport Meta Tag (add to HTML) =====
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes">
*/

/* ===== Base Responsive Improvements ===== */

/* Ensure all images are responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent horizontal overflow */
body, html {
    overflow-x: hidden;
    width: 100%;
}

/* ===== Mobile First: Extra Small Devices (320px - 480px) ===== */
@media (max-width: 480px) {
    /* Navigation */
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 0.8rem 15px;
        gap: 0.8rem;
    }
    
    .logo {
        font-size: 1.4rem;
        text-align: center;
    }
    
    .tab-buttons {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    
    .tab-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
        flex: 0 0 auto;
        min-width: 70px;
    }
    
    /* Adjust scroll container for mobile nav height */
    .scroll-container {
        margin-top: 120px;
    }
    
    .window-section {
        height: calc(100vh - 120px);
        min-height: 500px;
    }
    
    /* Home Section */
    .site-title {
        font-size: 1.8rem !important;
        line-height: 1.3;
        padding: 0 10px;
    }
    
    .main-subtitle {
        font-size: 1.1rem !important;
        padding: 0 10px;
    }
    
    .description {
        font-size: 0.9rem !important;
        padding: 0 10px;
        line-height: 1.5;
    }
    
    .download-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        width: 90%;
        max-width: 280px;
        margin: 0 auto;
    }
    
    /* Chat Options */
    .chat-options {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 0 10px;
    }
    
    .chat-option {
        min-width: 100%;
        max-width: 100%;
        padding: 1.2rem;
    }
    
    .option-btn {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }
    
    /* Screenshots */
    .app-screenshots {
        flex-wrap: wrap;
        gap: 0.8rem;
        justify-content: center;
    }
    
    .screenshot-item {
        flex: 0 0 calc(50% - 0.4rem);
        max-width: calc(50% - 0.4rem);
        min-width: 140px;
    }
    
    .screenshot-item img {
        border-radius: 10px;
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 1.2rem;
        padding: 0 10px;
    }
    
    .feature-card {
        padding: 1.3rem;
        min-height: auto;
    }
    
    .feature-card h3 {
        font-size: 1.1rem;
    }
    
    .feature-card p {
        font-size: 0.85rem;
    }
    
    /* Download Platforms */
    .download-platforms-horizontal {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
        padding: 0 10px;
    }
    
    .download-platform-btn {
        min-width: 110px !important;
        min-height: 150px !important;
        padding: 1rem 0.6rem !important;
        flex: 0 0 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
    }
    
    .download-platform-btn .platform-icon {
        width: 55px !important;
        height: 55px !important;
    }
    
    .text-arabic {
        font-size: 12px !important;
    }
    
    .text-english {
        font-size: 10px !important;
    }
    
    /* Contact Section */
    .contact-content {
        flex-direction: column;
        gap: 1.5rem;
        padding: 0 10px;
    }
    
    .social-icons {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .social-link {
        width: 100%;
        max-width: 100%;
        padding: 1rem;
    }
    
    .contact-info {
        width: 100%;
        max-width: 100%;
        padding: 1rem;
    }
    
    /* Legal Section */
    .legal-grid {
        grid-template-columns: 1fr !important;
        gap: 1.2rem;
        padding: 0 10px;
    }
    
    .legal-card {
        padding: 1.3rem;
    }
    
    /* Section Titles */
    .section-title {
        font-size: 1.8rem !important;
    }
    
    .secondary-title {
        font-size: 1.3rem !important;
    }
    
    /* Dot Navigation - Hide on very small screens */
    .dot-navigation {
        display: none;
    }
    
    /* Container padding */
    .container {
        padding: 0 10px;
    }
    
    /* Installer Features */
    .installer-features {
        padding: 0 10px;
    }
    
    .installer-features ul {
        padding-right: 20px;
    }
    
    .installer-features li {
        font-size: 0.85rem;
    }
}

/* ===== Small Devices (481px - 767px) ===== */
@media (min-width: 481px) and (max-width: 767px) {
    /* Navigation */
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 1rem 20px;
        gap: 1rem;
    }
    
    .logo {
        font-size: 1.6rem;
    }
    
    .tab-buttons {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .tab-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .scroll-container {
        margin-top: 130px;
    }
    
    .window-section {
        height: calc(100vh - 130px);
    }
    
    /* Home Section */
    .site-title {
        font-size: 2.2rem;
    }
    
    .main-subtitle {
        font-size: 1.4rem;
    }
    
    .description {
        font-size: 1rem;
    }
    
    /* Chat Options */
    .chat-options {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Screenshots */
    .screenshot-item {
        flex: 0 0 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    /* Download Platforms */
    .download-platform-btn {
        min-width: 130px;
        min-height: 170px;
        padding: 1.3rem 0.9rem;
    }
    
    .download-platform-btn .platform-icon {
        width: 65px;
        height: 65px;
    }
    
    /* Contact */
    .contact-content {
        flex-direction: column;
        gap: 2rem;
    }
    
    .social-icons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .social-link {
        flex: 0 0 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
    }
    
    /* Legal */
    .legal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    /* Dot Navigation */
    .dot-navigation {
        left: 20px;
    }
    
    .dot-btn {
        width: 12px;
        height: 12px;
    }
}

/* ===== Tablets (768px - 1024px) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Navigation */
    .nav-container {
        padding: 0 30px;
    }
    
    .logo {
        font-size: 1.7rem;
    }
    
    .tab-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    /* Home Section */
    .site-title {
        font-size: 2.8rem;
    }
    
    .main-subtitle {
        font-size: 1.6rem;
    }
    
    /* Chat Options */
    .chat-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    /* Screenshots */
    .screenshot-item {
        flex: 0 0 calc(33.333% - 0.67rem);
        max-width: calc(33.333% - 0.67rem);
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    /* Download Platforms */
    .download-platforms-horizontal {
        flex-wrap: wrap;
        gap: 1.5rem;
        justify-content: center;
    }
    
    .download-platform-btn {
        flex: 0 0 calc(33.333% - 1rem);
        max-width: 200px;
    }
    
    /* Contact */
    .contact-content {
        flex-wrap: wrap;
        gap: 1.5rem;
    }
    
    .social-icons {
        flex: 1 1 100%;
        flex-direction: row;
        gap: 1.5rem;
    }
    
    .social-link {
        flex: 1;
        min-width: 150px;
    }
    
    /* Legal */
    .legal-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ===== Large Tablets & Small Laptops (1025px - 1280px) ===== */
@media (min-width: 1025px) and (max-width: 1280px) {
    .container {
        max-width: 1100px;
    }
    
    .nav-container {
        max-width: 1100px;
    }
    
    /* Screenshots */
    .screenshot-item {
        flex: 0 0 calc(25% - 0.75rem);
        max-width: calc(25% - 0.75rem);
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Download Platforms */
    .download-platform-btn {
        flex: 0 0 auto;
    }
}

/* ===== Landscape Orientation Fixes ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .window-section {
        height: auto;
        min-height: 100vh;
        padding: 100px 0 50px 0;
    }
    
    .scroll-container {
        margin-top: 70px;
    }
    
    .site-title {
        font-size: 1.8rem;
    }
    
    .main-subtitle {
        font-size: 1.2rem;
    }
    
    .chat-options {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== Touch Device Improvements ===== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .tab-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .download-platform-btn {
        min-height: 160px;
    }
    
    .social-link {
        min-height: 60px;
    }
    
    .option-btn {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .tab-btn:hover,
    .download-platform-btn:hover,
    .social-link:hover,
    .feature-card:hover {
        transform: none;
    }
    
    /* Add active states for touch feedback */
    .tab-btn:active {
        transform: scale(0.95);
    }
    
    .download-platform-btn:active {
        transform: scale(0.98);
    }
}

/* ===== High DPI Screens (Retina) ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ===== Print Styles ===== */
@media print {
    .tab-navigation,
    .dot-navigation,
    .download-btn,
    .option-btn,
    .download-platform-btn {
        display: none;
    }
    
    .window-section {
        height: auto;
        page-break-inside: avoid;
    }
    
    body {
        background: white;
    }
}

/* ===== Accessibility Improvements ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ===== Dark Mode Support (Optional) ===== */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
    /* body {
        background: #1a1a1a;
        color: #f0f0f0;
    } */
}

/* ===== Very Small Screens (< 320px) ===== */
@media (max-width: 319px) {
    .site-title {
        font-size: 1.5rem !important;
    }
    
    .main-subtitle {
        font-size: 1rem !important;
    }
    
    .tab-btn {
        font-size: 0.65rem;
        padding: 0.3rem 0.5rem;
    }
    
    .download-platform-btn {
        min-width: 100px !important;
        min-height: 140px !important;
    }
    
    .download-platform-btn .platform-icon {
        width: 50px !important;
        height: 50px !important;
    }
}

/* ===== Extra Large Screens (> 1920px) ===== */
@media (min-width: 1921px) {
    .container {
        max-width: 1400px;
    }
    
    .nav-container {
        max-width: 1400px;
    }
    
    .site-title {
        font-size: 4rem;
    }
    
    .main-subtitle {
        font-size: 2.2rem;
    }
}

/* ===== Flexible Images in Grid ===== */
.screenshot-item img,
.feature-card img,
.legal-card img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ===== Prevent Text Overflow ===== */
.site-title,
.main-subtitle,
.section-title,
.secondary-title {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ===== Smooth Scrolling for Mobile ===== */
@media (max-width: 768px) {
    .scroll-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== Fix for iOS Safari Bottom Bar ===== */
@supports (-webkit-touch-callout: none) {
    .window-section {
        min-height: -webkit-fill-available;
    }
}

/* ===== Hamburger Menu (if needed for very small screens) ===== */
@media (max-width: 480px) {
    .tab-buttons {
        max-height: 200px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
