/* ===== RESPONSIVE CSS - مزمز ===== */
/* تحسين التجاوب لجميع الشاشات */

/* ===== BREAKPOINTS ===== */
/* Mobile: 320px - 767px */
/* Tablet: 768px - 1023px */
/* Desktop: 1024px+ */

/* ===== IMAGE LOADING OPTIMIZATIONS ===== */
/* تحسين تحميل الصور وإزالة placeholders */
img {
    max-width: 100%;
    height: auto;
    /* منع Chrome من وضع placeholders */
    image-rendering: auto;
}

/* تحسين الصور المهمة للعرض السريع */
.navbar-brand img, 
.hero-image,
.logo,
.favicon {
    /* تحسين الأولوية */
    opacity: 1;
    transition: none;
}

/* الصور الحيوية التي يجب عرضها فوراً */
.navbar-brand img,
.hero-section img,
img.logo,
img[src*="logo"],
img[src*="favicon"] {
    /* إزالة أي تأخير في العرض */
    transition: none !important;
    opacity: 1 !important;
}

/* تحسين عرض الصور العادية */
img[loading="lazy"] {
    transition: opacity 0.3s ease;
    will-change: opacity;
}

/* للصور التي لم تحمل بعد */
img:not([src]),
img[src=""],
img[src*="placeholder"] {
    opacity: 0.1;
    background: #f0f0f0;
}

/* ===== GLOBAL RESPONSIVE SETTINGS ===== */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    /* إصلاح مشكلة webkit-text-size-adjust */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

/* ===== MOBILE FIRST APPROACH ===== */

/* ===== MOBILE (320px - 767px) ===== */
@media (max-width: 767px) {
    /* Typography */
    html {
        font-size: 14px;
    }
    
    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.1rem; }
    h5, .h5 { font-size: 1rem; }
    h6, .h6 { font-size: 0.9rem; }
    
    /* Navigation */
    .navbar-brand {
        font-size: 1.2rem !important;
    }
    
    .navbar-nav .nav-link {
        padding: 0.5rem 1rem !important;
        font-size: 0.9rem;
        text-align: center;
    }
    
    .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Hero Sections */
    .hero-section {
        height: 50vh !important;
        min-height: 300px !important;
        max-height: 400px !important;
    }
    
    .hero-title {
        font-size: 1.8rem !important;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 0.9rem !important;
        line-height: 1.3;
    }
    
    /* Cards */
    .card, .product-card, .service-card {
        margin-bottom: 1rem;
        border-radius: 10px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
    
    .card-text {
        font-size: 0.9rem;
    }
    
    /* Images */
    .product-image, .service-image {
        height: 200px !important;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        border-radius: 20px;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        vertical-align: middle;
    }
    
    /* Grid System */
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .col, [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Spacing */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .section-padding {
        padding: 2rem 0;
    }
    
    /* Admin Panel Specific */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        z-index: 1000;
        transition: left 0.3s ease;
        width: 280px;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .main-content {
        margin-right: 0 !important;
        padding: 1rem;
    }
    
    .top-navbar {
        padding: 0.5rem 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    /* Modal */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Footer */
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer h5 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .footer p, .footer li {
        font-size: 0.9rem;
    }
    
    /* تحسينات إضافية للهاتف */
    /* Loading States */
    .loading-spinner {
        width: 30px;
        height: 30px;
        border: 3px solid #f3f3f3;
        border-top: 3px solid #D4A574;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin: 1rem auto;
    }
    
    .loading-text {
        text-align: center;
        color: #6c757d;
        font-size: 0.9rem;
        margin-top: 0.5rem;
    }
    
    /* Error Messages */
    .error-message {
        background: #f8d7da;
        color: #721c24;
        padding: 0.75rem;
        border-radius: 5px;
        border: 1px solid #f5c6cb;
        margin: 0.5rem 0;
        font-size: 0.9rem;
    }
    
    .success-message {
        background: #d4edda;
        color: #155724;
        padding: 0.75rem;
        border-radius: 5px;
        border: 1px solid #c3e6cb;
        margin: 0.5rem 0;
        font-size: 0.9rem;
    }
    
    /* Touch-friendly interactions */
    .btn, .nav-link, .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Improved scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    /* Better form spacing */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control:focus {
        box-shadow: 0 0 0 0.2rem rgba(212, 165, 116, 0.25);
        border-color: #D4A574;
    }
    
    /* Improved card interactions */
    .card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    /* Better spacing for mobile */
    .mb-mobile {
        margin-bottom: 1rem;
    }
    
    .mt-mobile {
        margin-top: 1rem;
    }
    
    /* Improved navigation */
    .navbar-nav .nav-link {
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
    
    /* Better modal handling */
    .modal-header {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Animations */
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    @keyframes slideIn {
        from { transform: translateX(-100%); }
        to { transform: translateX(0); }
    }
    
    .fade-in {
        animation: fadeIn 0.5s ease-out;
    }
    
    .slide-in {
        animation: slideIn 0.3s ease-out;
    }
    
    /* Smooth transitions */
    .btn, .card, .nav-link {
        transition: all 0.3s ease;
    }
    
    /* Loading overlay */
    .loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.8);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
    }
    
    .loading-overlay .spinner {
        width: 50px;
        height: 50px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #D4A574;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }
    
    /* Cart */
    .cart-item {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .quantity-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .quantity-controls input {
        width: 80px !important;
        text-align: center;
    }
    
    /* Reports */
    .stats-card {
        margin-bottom: 1rem;
    }
    
    .stats-card .card-body {
        padding: 1rem;
    }
    
    .stats-card h4 {
        font-size: 1.5rem;
    }
    
    .stats-card i {
        font-size: 2rem;
    }
}

/* ===== TABLET (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Typography */
    html {
        font-size: 15px;
    }
    
    h1, .h1 { font-size: 2.25rem; }
    h2, .h2 { font-size: 1.875rem; }
    h3, .h3 { font-size: 1.5rem; }
    h4, .h4 { font-size: 1.25rem; }
    h5, .h5 { font-size: 1.125rem; }
    h6, .h6 { font-size: 1rem; }
    
    /* Navigation */
    .navbar-brand {
        font-size: 1.4rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.6rem 1.2rem !important;
        font-size: 0.95rem;
    }
    
    /* Hero Sections */
    .hero-section {
        height: 55vh;
        min-height: 350px;
        max-height: 450px;
    }
    
    .hero-title {
        font-size: 2.25rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1.25rem;
    }
    
    .product-image, .service-image {
        height: 220px;
    }
    
    /* Admin Panel */
    .sidebar {
        width: 250px;
    }
    
    .main-content {
        margin-right: 250px;
    }
    
    .page-title {
        font-size: 1.75rem;
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Grid Adjustments */
    .col-md-6 {
        margin-bottom: 1.5rem;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 0.95rem;
        padding: 0.6rem 0.875rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.6rem 1.25rem;
        font-size: 0.95rem;
    }
    
    /* Spacing */
    .section-padding {
        padding: 3rem 0;
    }
    
    /* Footer */
    .footer {
        padding: 3rem 0 2rem;
    }
}

/* ===== DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
    /* Typography */
    html {
        font-size: 16px;
    }
    
    h1, .h1 { font-size: 2.5rem; }
    h2, .h2 { font-size: 2rem; }
    h3, .h3 { font-size: 1.75rem; }
    h4, .h4 { font-size: 1.5rem; }
    h5, .h5 { font-size: 1.25rem; }
    h6, .h6 { font-size: 1rem; }
    
    /* Navigation */
    .navbar-brand {
        font-size: 1.6rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem;
    }
    
    /* Hero Sections */
    .hero-section {
        height: 60vh;
        min-height: 400px;
        max-height: 500px;
    }
    
    .hero-title {
        font-size: 2.8rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1.5rem;
    }
    
    .product-image, .service-image {
        height: 250px;
    }
    
    /* Admin Panel */
    .sidebar {
        width: 280px;
    }
    
    .main-content {
        margin-right: 280px;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 1rem 0.75rem;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Spacing */
    .section-padding {
        padding: 4rem 0;
    }
    
    /* Footer */
    .footer {
        padding: 4rem 0 2rem;
    }
}

/* ===== LARGE DESKTOP (1200px+) ===== */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-subtitle {
        font-size: 1.2rem;
    }
    
    .product-image, .service-image {
        height: 280px;
    }
}

/* ===== EXTRA LARGE DESKTOP (1400px+) ===== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .hero-title {
        font-size: 3.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.3rem;
    }
    
    .product-image, .service-image {
        height: 300px;
    }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-section {
        height: 100vh;
        min-height: 100vh;
    }
    
    .hero-title {
        font-size: 1.8rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .card:hover,
    .product-card:hover,
    .service-card:hover {
        transform: none !important;
    }
    
    .btn:hover {
        transform: none !important;
    }
    
    /* Increase touch targets */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    /* Improve scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== HIGH DPI DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image,
    .service-image,
    .hero-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .navbar,
    .footer,
    .btn,
    .sidebar,
    .top-navbar {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .hero-section {
        height: auto !important;
        min-height: auto !important;
    }
    
    .hero-image {
        display: none !important;
    }
    
    .hero-content {
        color: #000 !important;
        text-shadow: none !important;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    /* This will be handled by the existing dark mode CSS variables */
}

/* ===== SPECIFIC COMPONENT RESPONSIVE FIXES ===== */

/* Booking Modal */
@media (max-width: 767px) {
    .booking-modal .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .booking-modal .modal-body {
        padding: 1rem;
    }
    
    .booking-form .row {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }
    
    .booking-form .col,
    .booking-form [class*="col-"] {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}

/* Cart Page */
@media (max-width: 767px) {
    .cart-summary {
        position: static;
        margin-top: 1rem;
    }
    
    .cart-item-details {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .cart-item-image {
        width: 100%;
        height: 150px;
        object-fit: cover;
    }
}

/* Reports Page */
@media (max-width: 767px) {
    .reports-filter {
        flex-direction: column;
        gap: 1rem;
    }
    
    .reports-filter .col-md-3 {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* Admin Tables */
@media (max-width: 767px) {
    .admin-table .table {
        font-size: 0.8rem;
    }
    
    .admin-table .btn-group {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .admin-table .btn-group .btn {
        width: 100%;
        margin: 0;
    }
}

/* Product/Service Cards */
@media (max-width: 767px) {
    .product-grid,
    .service-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .product-grid,
    .service-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .product-grid,
    .service-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
}

/* ===== UTILITY CLASSES ===== */
.d-none-mobile {
    display: none;
}

@media (min-width: 768px) {
    .d-none-mobile {
        display: block;
    }
    
    .d-none-desktop {
        display: none;
    }
}

.text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .text-center-mobile {
        text-align: left;
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
@media (max-width: 767px) {
    /* Reduce animations on mobile for better performance */
    .card,
    .product-card,
    .service-card {
        transition: none;
    }
    
    /* Optimize images for mobile */
    .product-image,
    .service-image {
        image-rendering: optimizeSpeed;
    }
}

/* ===== SAFE AREA SUPPORT (iOS) ===== */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .footer {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

