/* Karmone Responsive Styles - Optimized */

/* Large devices (desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Medium devices (tablets, 992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    .header-main .container {
        gap: 20px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .vendors-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* اصلاح فاصله‌ها */
    .hero-section {
        padding: 40px 0 !important;
        margin-bottom: 25px !important;
    }
    
    .categories-section,
    .products-section,
    .vendors-section,
    .features-section,
    .newsletter-section {
        padding: 35px 0 !important;
    }
    
    .section-title {
        margin-bottom: 25px !important;
    }
}

/* Small devices (landscape phones, 768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px;
    }
    
    /* Header */
    .header-desktop {
        display: none;
    }
    
    .header-mobile {
        display: block;
        padding: 12px 0;
    }
    
    .header-mobile .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-logo img {
        max-height: 38px;
    }
    
    .mobile-menu-toggle {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-color);
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius);
        transition: var(--transition);
    }
    
    .mobile-menu-toggle:hover {
        background-color: var(--bg-light);
    }
    
    /* Mobile Menu */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100vh;
        background-color: var(--bg-color);
        box-shadow: var(--shadow-lg);
        transition: var(--transition);
        z-index: 1100;
        overflow-y: auto;
    }
    
    .mobile-menu.active {
        left: 0;
    }
    
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-bottom: 1px solid var(--border-color);
        background-color: var(--bg-light);
    }
    
    .mobile-menu-close {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-color);
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius);
        transition: var(--transition);
    }
    
    .mobile-menu-close:hover {
        background-color: rgba(0, 0, 0, 0.1);
    }
    
    .mobile-menu-nav {
        padding: 20px;
    }
    
    .mobile-menu-nav ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    .mobile-menu-nav li {
        margin-bottom: 8px;
    }
    
    .mobile-menu-nav a {
        display: block;
        padding: 12px 15px;
        color: var(--text-color);
        border-bottom: 1px solid var(--border-light);
        border-radius: var(--radius);
        transition: var(--transition);
    }
    
    .mobile-menu-nav a:hover {
        background-color: var(--bg-light);
        color: var(--primary-color);
        text-decoration: none;
    }
    
    .mobile-menu-actions {
        padding: 20px;
        border-top: 1px solid var(--border-color);
        background-color: var(--bg-light);
    }
    
    /* Hero Section - اصلاح شده */
    .hero-section {
        padding: 35px 0 !important;
        margin-bottom: 25px !important;
    }
    
    .hero-content h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .hero-content p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* Grid Layouts */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .vendors-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* اصلاح فاصله‌های اضافی */
    .categories-section,
    .products-section,
    .vendors-section,
    .features-section,
    .newsletter-section {
        padding: 35px 0 !important;
    }
    
    .section-title {
        margin-bottom: 25px !important;
    }
    
    .section-title h2 {
        font-size: 1.75rem;
    }
    
    .section-title p {
        font-size: 0.9375rem;
    }
    
    /* Footer */
    .footer-widgets {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
    
    /* WooCommerce */
    .single-product .product {
        grid-template-columns: 1fr;
    }
    
    .cart-collaterals {
        grid-template-columns: 1fr;
    }
    
    .woocommerce-checkout {
        grid-template-columns: 1fr;
    }
    
    #customer_details {
        padding-right: 0;
        margin-bottom: 30px;
    }
    
    /* Dokan */
    .dokan-dashboard-content {
        grid-template-columns: 1fr;
    }
    
    .dokan-dash-sidebar {
        margin-bottom: 25px;
    }
    
    .store-info {
        flex-direction: column;
        text-align: center;
    }
    
    .store-avatar {
        margin-top: -50px;
    }
}

/* Extra small devices (portrait phones, less than 768px) */
@media (max-width: 767px) {
    .container {
        max-width: 100%;
        padding: 0 12px;
    }
    
    /* Header */
    .header-desktop {
        display: none;
    }
    
    .header-mobile {
        display: block;
        padding: 10px 0;
    }
    
    /* Hero Section - اصلاح شده */
    .hero-section {
        padding: 30px 0 !important;
        margin-bottom: 20px !important;
    }
    
    .hero-content h1 {
        font-size: 1.75rem;
        margin-bottom: 0.875rem;
    }
    
    .hero-content p {
        font-size: 0.9375rem;
        margin-bottom: 1.25rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Section Titles */
    .section-title h2 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .section-title p {
        font-size: 0.875rem;
        margin-top: 0.5rem;
    }
    
    .section-title {
        margin-bottom: 20px !important;
    }
    
    /* Grid Layouts */
    .categories-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .vendors-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* اصلاح فاصله‌های اضافی */
    .categories-section,
    .products-section,
    .vendors-section,
    .features-section,
    .newsletter-section {
        padding: 25px 0 !important;
    }
    
    /* Products Filter */
    .products-filter {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .filter-options {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    /* Newsletter */
    .newsletter-form {
        flex-direction: column;
        gap: 10px;
    }
    
    .newsletter-form input {
        width: 100%;
    }
    
    /* Footer */
    .footer-widgets {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .footer-bottom {
        text-align: center;
        padding: 20px 0;
    }
    
    /* WooCommerce */
    .woocommerce .products {
        grid-template-columns: 1fr;
    }
    
    .woocommerce .product {
        margin-bottom: 20px;
    }
    
    .shop_table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .cart_totals {
        margin-top: 25px;
    }
    
    .coupon {
        flex-direction: column;
        width: 100%;
    }
    
    .coupon input {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    /* Dokan */
    .karmone-store-header {
        margin-bottom: 15px;
    }
    
    .store-banner {
        height: 180px;
    }
    
    .store-info {
        padding: 15px;
        margin-top: -30px;
    }
    
    .store-avatar {
        width: 80px;
        height: 80px;
    }
    
    .store-name {
        font-size: 1.25rem;
    }
    
    .dokan-store-tabs {
        flex-direction: column;
    }
    
    .dokan-store-tabs li {
        margin-right: 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .dokan-store-tabs li:last-child {
        border-bottom: none;
    }
    
    .dokan-store-tabs a {
        padding: 12px 0;
    }
    
    .vendor-dashboard-header {
        padding: 15px;
    }
    
    .vendor-dashboard-header h1 {
        font-size: 1.25rem;
    }
    
    .vendor-stats {
        grid-template-columns: 1fr;
    }
    
    .dokan-dashboard-widgets {
        grid-template-columns: 1fr;
    }
    
    .dokan-dashboard-content-area {
        padding: 15px;
    }
    
    .product-listing-top {
        flex-direction: column;
        gap: 12px;
    }
    
    .product-search {
        width: 100%;
    }
    
    .product-search input {
        flex: 1;
    }
    
    /* Vendor Registration */
    .registration-form {
        padding: 15px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-prev,
    .btn-next,
    .btn-submit {
        width: 100%;
    }
    
    /* اصلاح کلی فضای خالی */
    .site-main {
        padding: 15px 0 30px !important;
    }
    
    .page-content {
        padding: 20px 0 !important;
    }
    
    .page-header {
        padding-top: 15px !important;
        padding-bottom: 15px !important;
        margin-bottom: 15px !important;
    }
}

/* Very small devices (portrait phones, less than 576px) */
@media (max-width: 575px) {
    /* Typography */
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.375rem;
        margin-bottom: 0.875rem;
    }
    
    h3 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    /* Hero - اصلاح بیشتر */
    .hero-section {
        padding: 25px 0 !important;
        margin-bottom: 15px !important;
    }
    
    .hero-content h1 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .hero-content p {
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 20px;
        font-size: 0.875rem;
        min-height: 42px;
    }
    
    /* Forms */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Product Card */
    .product-image {
        height: 180px;
    }
    
    /* Vendor Card */
    .vendor-banner {
        height: 100px;
    }
    
    .vendor-avatar-large {
        width: 60px;
        height: 60px;
        top: -30px;
    }
    
    .vendor-details {
        margin-top: 25px;
    }
    
    /* Tables */
    .product-listing-table,
    .orders-table {
        font-size: 0.8125rem;
    }
    
    .product-listing-table th,
    .product-listing-table td,
    .orders-table th,
    .orders-table td {
        padding: 8px 4px;
    }
    
    /* Modal Windows */
    .modal-dialog {
        margin: 8px;
    }
    
    .modal-content {
        padding: 15px 12px;
    }
    
    /* اصلاح نهایی فاصله‌ها */
    .site-main {
        padding: 10px 0 25px !important;
    }
    
    .page-content {
        padding: 15px 0 !important;
    }
    
    .page-header {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
        margin-bottom: 10px !important;
    }
    
    .categories-section,
    .products-section,
    .vendors-section,
    .features-section,
    .newsletter-section {
        padding: 20px 0 !important;
    }
}

/* Print Styles */
@media print {
    .site-header,
    .site-footer,
    .hero-section,
    .newsletter-section,
    .dokan-dash-sidebar,
    .product-actions,
    .vendor-actions,
    .btn {
        display: none !important;
    }
    
    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000 !important;
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    a {
        color: #000 !important;
        text-decoration: underline !important;
    }
    
    .page-break {
        page-break-before: always;
    }
    
    .no-print {
        display: none !important;
    }
    
    /* اصلاح فاصله در پرینت */
    .site-main {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .page-content {
        padding: 0 !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --text-color: #000000;
        --text-light: #333333;
        --border-color: #000000;
        --primary-color: #0000ff;
        --secondary-color: #ff0000;
    }
    
    body {
        background-color: #ffffff;
        color: #000000;
    }
    
    a {
        text-decoration: underline;
    }
    
    /* اصلاح فاصله در حالت کنتراست بالا */
    .hero-section,
    .categories-section,
    .products-section {
        border: 2px solid #000000 !important;
        margin-bottom: 20px !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hero-buttons .btn:hover,
    .product-card:hover,
    .vendor-card:hover,
    .feature-card:hover {
        transform: none !important;
    }
    
    .product-image img,
    .category-image img {
        transition: none !important;
    }
    
    /* اصلاح فاصله ثابت */
    .hero-section {
        margin-bottom: 20px !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #e0e0e0;
        --text-light: #a0a0a0;
        --text-lighter: #707070;
        --border-color: #404040;
        --border-light: #303030;
        --bg-color: #121212;
        --bg-light: #1e1e1e;
        --bg-lighter: #2a2a2a;
    }
    
    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }
    
    .site-header,
    .site-footer,
    .product-card,
    .vendor-card,
    .feature-card,
    .category-card {
        background-color: var(--bg-light);
    }
    
    .header-top,
    .header-navigation,
    .dokan-store-sidebar,
    .dokan-dash-sidebar {
        background-color: var(--bg-lighter);
    }
    
    .hero-section,
    .newsletter-section {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    input,
    select,
    textarea {
        background-color: var(--bg-lighter);
        color: var(--text-color);
        border-color: var(--border-color);
    }
    
    .search-field,
    .form-control {
        background-color: var(--bg-lighter);
        color: var(--text-color);
    }
    
    .modal-content,
    .cart-dropdown,
    .user-dropdown,
    .category-menu {
        background-color: var(--bg-light);
        border-color: var(--border-color);
    }
    
    /* اصلاح فاصله در دارک مود */
    .hero-section {
        margin-bottom: 25px !important;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-width: 900px) {
    .hero-section {
        padding: 25px 0 !important;
        margin-bottom: 20px !important;
    }
    
    .hero-content h1 {
        font-size: 1.75rem;
    }
    
    .categories-grid,
    .products-grid,
    .vendors-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* اصلاح فاصله‌ها */
    .site-main {
        padding: 15px 0 25px !important;
    }
}

/* Portrait Orientation */
@media (orientation: portrait) and (max-width: 600px) {
    .mobile-menu {
        width: 100%;
    }
    
    .hero-section {
        padding: 20px 0 !important;
        margin-bottom: 15px !important;
    }
    
    .hero-content h1 {
        font-size: 1.375rem;
    }
    
    .categories-grid,
    .products-grid,
    .vendors-grid {
        grid-template-columns: 1fr;
    }
    
    /* اصلاح فاصله‌های اضافی */
    .site-main {
        padding: 10px 0 20px !important;
    }
    
    .page-content {
        padding: 15px 0 !important;
    }
}

/* Touch Device Optimization */
@media (hover: none) and (pointer: coarse) {
    .product-actions,
    .vendor-actions {
        position: static;
        opacity: 1;
        background-color: transparent;
        padding: 10px 0 0;
        transform: none !important;
    }
    
    .user-dropdown,
    .cart-dropdown,
    .category-menu {
        position: fixed;
        top: auto !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        max-height: 60vh;
        overflow-y: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    
    .user-dropdown.active,
    .cart-dropdown.active,
    .category-menu.active {
        transform: translateY(0);
    }
    
    .dropdown-toggle::after {
        content: '▼';
        font-size: 0.75rem;
        margin-left: 5px;
    }
    
    /* Larger touch targets */
    .main-navigation a,
    .dokan-dashboard-menu a,
    .dokan-store-tabs a,
    .filter-btn,
    .action-btn,
    .product-action-btn {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects */
    .product-card:hover,
    .vendor-card:hover,
    .feature-card:hover,
    .category-card:hover {
        transform: none !important;
        box-shadow: var(--shadow);
    }
    
    /* Increase font sizes for readability */
    body {
        font-size: 17px;
    }
    
    h1 { 
        font-size: 1.5rem;
        margin-bottom: 0.875rem;
    }
    
    h2 { 
        font-size: 1.375rem;
        margin-bottom: 0.75rem;
    }
    
    h3 { 
        font-size: 1.25rem;
        margin-bottom: 0.625rem;
    }
    
    .product-title,
    .vendor-name,
    .store-name {
        font-size: 1.125rem;
    }
    
    /* اصلاح فاصله برای تاچ */
    .hero-section {
        margin-bottom: 20px !important;
        padding: 30px 0 !important;
    }
    
    .site-main {
        padding: 20px 0 35px !important;
    }
}

/* Desktop Hover States */
@media (hover: hover) and (pointer: fine) {
    .product-actions {
        bottom: -50px;
    }
    
    .product-card:hover .product-actions {
        bottom: 0;
    }
    
    .user-menu:hover .user-dropdown,
    .header-cart:hover .cart-dropdown,
    .category-dropdown:hover .category-menu {
        display: block;
    }
    
    /* Smooth scroll for anchor links */
    html {
        scroll-behavior: smooth;
    }
}

/* iOS Safe Areas */
@supports (padding: max(0px)) {
    .site-header,
    .site-footer {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .mobile-menu {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* اصلاح فاصله در iOS */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .hero-section {
        margin-top: calc(0px - env(safe-area-inset-top));
        padding-top: calc(40px + env(safe-area-inset-top)) !important;
    }
}

/* Additional Fixes for Spacing Issues */
@media (max-width: 767px) {
    /* حذف margin و padding اضافی از عناصر داخلی */
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    .col-lg-8,
    .col-lg-4 {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* اصلاح فاصله در صفحات داخلی */
    .page .entry-content {
        margin-top: 0;
        padding-top: 0;
    }
    
    /* اصلاح فاصله در کامنت‌ها */
    .comments-area {
        margin-top: 20px;
        padding-top: 20px;
    }
}

/* Force Remove Extra Spacing */
.hero-section {
    margin-bottom: 30px !important;
}

@media (max-width: 991px) {
    .hero-section {
        margin-bottom: 25px !important;
    }
}

@media (max-width: 767px) {
    .hero-section {
        margin-bottom: 20px !important;
    }
}

@media (max-width: 575px) {
    .hero-section {
        margin-bottom: 15px !important;
    }
}