/**
 * تحسينات التصميم المتجاوب المتقدمة
 * Advanced Responsive Design Enhancements
 */

/* ===== MOBILE-FIRST APPROACH ===== */

/* تحسينات الخطوط للأجهزة المختلفة */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    /* body {
        font-size: 16px;
        line-height: 1.5;
    } */
    
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.6rem; }
    h3 { font-size: 1.4rem; }
    h4 { font-size: 1.2rem; }
    h5 { font-size: 1.1rem; }
    h6 { font-size: 1rem; }
}

@media (min-width: 481px) and (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.8rem; }
    h3 { font-size: 1.6rem; }
}

@media (min-width: 769px) {
    html {
        font-size: 12px;
    }
}

/* ===== HEADER RESPONSIVE ===== */
@media (max-width: 768px) {
    .header {
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 1000;
    }
    
    .top-bar {
        padding: 8px 0;
        font-size: 12px;
    }
    
    .top-bar .container {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 10px;
    }
    
    .contact-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .contact-info a {
        font-size: 12px;
        padding: 5px 8px;
    }
    
    .download-profile-btn {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .main-nav .container {
        flex-direction: column;
        padding: 10px 15px;
    }
    
    .header-logo {
        width: 60px;
        height: auto;
        margin-bottom: 10px;
    }
    
    .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 5px;
        margin-bottom: 10px;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .nav-menu a {
        display: block;
        padding: 10px 15px;
        text-align: center;
        border-radius: 5px;
        background: var(--light-bg);
        margin-bottom: 2px;
    }
    
    .search-box {
        width: 100%;
        max-width: 300px;
    }
    
    .search-input {
        font-size: 14px;
        padding: 8px 35px 8px 12px;
    }
}

/* ===== HERO SECTION RESPONSIVE ===== */
@media (max-width: 768px) {
    .hero {
        height: 100vh;
        padding-top: 120px;
    }
    
    .hero-content h2 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 15px;
    }
    
    .hero-content p {
        font-size: 0.9rem;
        line-height: 1.4;
        margin-bottom: 20px;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .hero-btn {
        width: 100%;
        max-width: 250px;
        padding: 12px 20px;
        font-size: 14px;
        text-align: center;
    }
    
    .hero-badge img {
        width: 80px;
        height: auto;
    }
}

/* ===== SERVICES RESPONSIVE ===== */
@media (max-width: 768px) {
    .services-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 10px;
    }
    
    .service-card {
        padding: 20px 15px;
        text-align: center;
    }
    
    .service-icon {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    .service-card h4 {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }
    
    .service-card p {
        font-size: 0.9rem;
        line-height: 1.4;
    }
}

/* ===== QUICK ACCESS RESPONSIVE ===== */
@media (max-width: 768px) {
    .quick-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 0 10px;
    }
    
    .quick-card {
        padding: 15px 10px;
        text-align: center;
    }
    
    .quick-icon {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .quick-card h4 {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    .quick-card p {
        font-size: 0.8rem;
        line-height: 1.3;
    }
}

@media (max-width: 480px) {
    .quick-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .quick-card {
        padding: 20px 15px;
    }
}

/* ===== ACHIEVEMENTS RESPONSIVE ===== */
@media (max-width: 768px) {
    .achievements-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 10px;
    }
    
    .achievement-card {
        padding: 20px 15px;
        text-align: center;
    }
    
    .achievement-number {
        font-size: 2rem;
    }
    
    .achievement-card h4 {
        font-size: 1rem;
    }
    
    .achievement-card p {
        font-size: 0.85rem;
    }
}

/* ===== FORMS RESPONSIVE ===== */
@media (max-width: 768px) {
    .consultation-form {
        padding: 20px 15px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 12px;
        font-size: 16px; /* منع الزوم في iOS */
        border-radius: 8px;
    }
    
    .form-group textarea {
        min-height: 100px;
    }
    
    .form-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .submit-btn {
        width: 100%;
        padding: 15px;
        font-size: 16px;
    }
    
    /* تحسينات النماذج المحسنة */
    .enhanced-field {
        margin-bottom: 15px;
    }
    
    .form-progress {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .progress-text {
        font-size: 12px;
    }
    
    .validation-summary {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .error-message,
    .success-message {
        font-size: 12px;
    }
}

/* ===== FOOTER RESPONSIVE ===== */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }
    
    .footer-section {
        padding: 0 20px;
    }
    
    .footer-section h4 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .footer-section p,
    .footer-section a {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .social-links {
        justify-content: center;
        gap: 15px;
    }
    
    .social-links a {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* ===== FLOATING ELEMENTS RESPONSIVE ===== */
@media (max-width: 768px) {
    .whatsapp-float {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
        font-size: 1.5rem;
    }
    
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 80px;
        right: 20px;
        font-size: 1.2rem;
    }
}

/* ===== MODAL AND POPUP RESPONSIVE ===== */
@media (max-width: 768px) {
    .modal,
    .popup {
        width: 95%;
        max-width: none;
        margin: 20px auto;
        border-radius: 10px;
    }
    
    .modal-content,
    .popup-content {
        padding: 20px 15px;
    }
    
    .modal-header h3,
    .popup-header h3 {
        font-size: 1.2rem;
    }
    
    .modal-close,
    .popup-close {
        top: 10px;
        right: 15px;
        font-size: 1.5rem;
    }
}

/* ===== TABLES RESPONSIVE ===== */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 14px;
    }
    
    th, td {
        padding: 8px 6px;
        white-space: nowrap;
    }
}

/* ===== CARDS AND GRIDS RESPONSIVE ===== */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card {
        margin-bottom: 15px;
    }
    
    .card-header {
        padding: 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .card-footer {
        padding: 10px 15px;
    }
}

/* ===== IMAGES RESPONSIVE ===== */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .lawyer-image img {
        width: 100%;
        max-width: 300px;
        margin: 0 auto 20px;
        display: block;
    }
    
    .about-content {
        flex-direction: column;
        text-align: center;
    }
    
    .about-text {
        order: 2;
    }
    
    .lawyer-image {
        order: 1;
        margin-bottom: 20px;
    }
}

/* ===== TOUCH IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    /* تحسينات للأجهزة اللمسية */
    button,
    .btn,
    a {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    .nav-menu a {
        padding: 15px 20px;
    }
    
    .quick-card,
    .service-card {
        padding: 20px;
    }
    
    /* إزالة hover effects على الأجهزة اللمسية */
    .service-card:hover,
    .quick-card:hover,
    .achievement-card:hover {
        transform: none;
        box-shadow: inherit;
    }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        height: 100vh;
        padding-top: 80px;
    }
    
    .hero-content h2 {
        font-size: 1.3rem;
    }
    
    .hero-content p {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }
    
    .hero-buttons {
        flex-direction: row;
        justify-content: center;
        gap: 15px;
    }
    
    .hero-btn {
        width: auto;
        min-width: 150px;
    }
}

/* ===== VERY SMALL SCREENS ===== */
@media (max-width: 320px) {
    .container {
        padding: 0 10px;
    }
    
    .hero-content h2 {
        font-size: 1.3rem;
    }
    
    .hero-content p {
        font-size: 0.85rem;
    }
    
    .service-card,
    .quick-card,
    .achievement-card {
        padding: 15px 10px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 10px;
    }
    
    .submit-btn {
        padding: 12px;
        font-size: 14px;
    }
}

/* ===== LARGE SCREENS OPTIMIZATIONS ===== */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .quick-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1600px) {
    .container {
        max-width: 1600px;
    }
    
    .services-grid,
    .quick-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
    
    .header,
    .whatsapp-float,
    .back-to-top,
    .form-buttons {
        display: none !important;
    }
    
    .hero {
        height: auto;
        padding: 20px 0;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    .service-card,
    .quick-card,
    .achievement-card {
        break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #ffffff;
        --text-color: #000000;
        --border-color: #000000;
    }
    
    .service-card,
    .quick-card,
    .achievement-card {
        border: 2px solid #000000;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4a9eff;
        --secondary-color: #1a1a1a;
        --text-color: #e0e0e0;
        --light-bg: #2a2a2a;
        --white: #1a1a1a;
        --border-color: #404040;
    }
    
    
    .service-card,
    .quick-card,
    .achievement-card,
    .form-group input,
    .form-group textarea,
    .form-group select {
        /* background-color: #2a2a2a; */
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .header {
        /* background-color: #1a1a1a; */
        /* border-bottom: 1px solid #404040; */
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s;
}

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

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* تحسين الأداء للأنيميشن */
.smooth-scroll {
    scroll-behavior: smooth;
}

@supports (scroll-behavior: smooth) {
    html {
        scroll-behavior: smooth;
    }
}

/* ===== UTILITY CLASSES ===== */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}

.text-center-mobile {
    text-align: inherit;
}

@media (max-width: 768px) {
    .text-center-mobile {
        text-align: center !important;
    }
}
