/* ===== MODERN HEADER MOBILE OPTIMIZATION ===== */
/* بهینه‌سازی هدر مدرن برای موبایل */

/* Mobile First Approach */
@media (max-width: 1024px) {
  
  /* Header Container Mobile */
  .modern-header {
    min-height: 60px;
    padding: 0;
    background: #ffffff !important;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  .header-topbar {
    display: none !important;
    margin: 0;
    padding: 0;
  }
  
  .header-container {
    padding: 0 1rem;
    gap: 1rem;
  }
  
  /* Logo Mobile Optimization */
  .header-logo {
    flex-shrink: 0;
  }
  
  .logo-link {
    gap: 0.5rem;
    min-width: auto;
  }
  
  .logo-icon {
    width: 40px;
    height: 40px;
    font-size: 1.125rem;
    flex-shrink: 0;
  }
  
  .logo-text {
    display: flex !important; /* Show text on mobile */
    flex-direction: column;
    flex-shrink: 1;
    min-width: 0;
  }
  
  .logo-title {
    font-size: 1rem;
    /* اطمینان از نمایش عنوان روی موبایل */
    display: block !important;
    color: #212529 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .logo-subtitle {
    font-size: 0.75rem;
    /* اطمینان از نمایش زیرعنوان روی موبایل */
    display: block !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Hide desktop navigation */
  .header-navigation {
    display: none;
  }
  
  /* Mobile Toggle Button */
  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #0d6efd !important;
    border: 1px solid rgba(13, 110, 253, 0.3);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--header-transition-fast);
    position: relative;
    color: var(--header, #ffffff);
  }
  
  .mobile-toggle:hover {
    background: var(--header-primary);
    color: var(--header-text-light);
    border-color: var(--header-primary);
    transform: scale(1.05);
  }
  
  .mobile-toggle:active {
    transform: scale(0.95);
  }
  
  /* Hamburger Animation */
  .hamburger {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 20px;
    height: 16px;
    transition: var(--header-transition-fast);
  }
  
  .hamburger span {
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: var(--header-transition-fast);
  }
  
  /* Mobile Navigation */
  .mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 350px;
    height: 100vh;
    background: #ffffff !important;
    border-left: 1px solid #e9ecef;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    transition: var(--header-transition);
    overflow-y: auto;
    direction: rtl;
  }
  
  .mobile-nav.active {
    right: 0;
  }
  
  .mobile-nav-content {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa !important;
    min-height: 60px;
  }
  
  .mobile-nav-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--header-text);
  }
  
  .mobile-close {
    width: 40px;
    height: 40px;
    background: var(--header-primary);
    color: var(--header-text-light);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--header-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-close:hover {
    background: var(--header-primary-hover);
    transform: scale(1.05);
  }
  
  .mobile-close:active {
    transform: scale(0.95);
  }
  
  .mobile-nav-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #ffffff !important;
  }
  
  /* Mobile Menu Items */
  .mobile-menu {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  .mobile-menu li {
    margin-bottom: 0.5rem;
  }
  
  .mobile-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #212529 !important;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 1rem;
    transition: var(--header-transition-fast);
    background: transparent !important;
    border: none;
    width: 100%;
    text-align: right;
  }
  
  .mobile-link:hover {
    background: rgba(13, 110, 253, 0.1) !important;
    color: #0d6efd !important;
    transform: translateX(-2px);
  }
  
  .mobile-link:active {
    transform: translateX(-1px);
  }

  .mobile-link.active {
    background: rgba(13, 110, 253, 0.12) !important;
    color: var(--header-primary) !important;
  }

  .mobile-sublink {
    padding-right: 2rem;
    font-size: 0.95rem;
  }
  
  .mobile-link i {
    width: 20px;
    text-align: center;
    color: #0d6efd !important;
    font-size: 1.125rem;
  }
  
  /* Mobile Auth Section */
  .mobile-auth {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    background: #ffffff !important;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .mobile-auth form {
    width: 100%;
  }

  .mobile-auth button {
    width: 100%;
  }

  .mobile-quick-actions {
    margin: 1rem 0 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .mobile-quick-action {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--border-radius);
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd !important;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
  }

  .mobile-quick-action:hover,
  .mobile-quick-action:focus-visible {
    background: rgba(13, 110, 253, 0.18);
    outline: none;
  }

  .mobile-quick-action i {
    width: 20px;
    text-align: center;
  }

  .mobile-contact-card {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    background: rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-contact-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #212529;
    font-size: 0.95rem;
  }

  .mobile-contact-row i {
    color: #0d6efd;
  }

  .mobile-contact-row a {
    color: inherit;
    text-decoration: none;
  }

  /* Mobile Social Links */
  .mobile-social-links {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    background: rgba(15, 23, 42, 0.04);
  }

  .mobile-social-title {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
    text-align: center;
  }

  .mobile-social-icons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .mobile-social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(13, 110, 253, 0.1);
    border-radius: 50%;
    color: #0d6efd;
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s ease;
  }

  .mobile-social-icon:hover {
    background: #0d6efd;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3);
  }

  .mobile-search {
    margin-bottom: 1.25rem;
  }

  .mobile-search-form {
    width: 100%;
  }

  .mobile-search-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(13, 110, 253, 0.08);
    border-radius: var(--border-radius);
    padding: 0.6rem 0.75rem;
    color: #0d6efd;
  }

  .mobile-search-group input {
    border: none;
    background: transparent;
    flex: 1;
    color: #0d6efd;
    font-weight: 500;
  }

  .mobile-search-group input::placeholder {
    color: rgba(13, 110, 253, 0.6);
  }

  .mobile-search-group button {
    border: none;
    background: rgba(13, 110, 253, 0.15);
    color: #0d6efd;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--border-radius);
    background: rgba(15, 23, 42, 0.05);
    margin-top: 1.5rem;
  }

  .mobile-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #0d6efd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    overflow: hidden;
  }

  .mobile-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .mobile-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9rem;
  }
  
  .mobile-auth .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: var(--header-transition-fast);
    text-decoration: none;
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .mobile-auth .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--header-shadow-hover);
  }
  
  .mobile-auth .btn:active {
    transform: translateY(0);
  }
  
  /* User Section Mobile */
  .user-section {
    gap: 0.5rem;
  }
  
  .user-name {
    display: none; /* Hide user name on mobile */
  }
  
  .user-btn {
    padding: 0.5rem;
    gap: 0.25rem;
  }
  
  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.875rem;
  }
  
  /* User Dropdown Mobile */
  .user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--header-transition);
    padding: 0.5rem 0;
  }
  
  .user-profile:hover .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  
  .user-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #212529 !important;
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--header-transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    cursor: pointer;
  }
  
  .user-dropdown .dropdown-item:hover {
    background: rgba(13, 110, 253, 0.1) !important;
    color: #0d6efd !important;
  }
  
  .user-dropdown .dropdown-item i {
    width: 16px;
    text-align: center;
    color: #0d6efd !important;
  }
  
  .dropdown-divider {
    height: 1px;
    background: #e9ecef !important;
    margin: 0.5rem 0;
  }
  
  .logout-btn {
    color: #dc3545 !important;
  }
  
  .logout-btn:hover {
    background: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
  }
  
  /* Auth Buttons Mobile */
  .auth-buttons {
    gap: 0.25rem;
  }
  
  .auth-buttons .btn {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .auth-buttons .btn span {
    display: none; /* Hide text on mobile */
  }
  
  /* Action Buttons Mobile */
  .action-btn {
    width: 40px;
    height: 40px;
  }
  
  .header-spacer {
    height: 60px;
  }

  .header-actions {
    gap: 0.6rem;
    justify-content: flex-end;
  }
  
  .sidebar-toggle {
    display: none !important;
  }
  
  /* Search Modal Mobile */
  .search-modal-content {
    width: 95%;
    max-width: 400px;
    margin: 1rem;
  }
  
  .search-header {
    padding: 0.75rem 1rem;
  }
  
  .search-header h3 {
    font-size: 1rem;
  }
  
  .search-close {
    width: 28px;
    height: 28px;
    font-size: 0.875rem;
  }
  
  .search-body {
    padding: 1rem;
  }
  
  .search-input {
    font-size: 1rem;
    padding: 0.75rem;
  }
  
  .search-submit {
    padding: 0.75rem 1rem;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  
  .modern-header {
    height: 55px;
  }
  
  .header-container {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .header-cta-mobile {
    width: 36px;
    height: 36px;
  }
  
  .logo-icon {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }
  
  .logo-text {
    display: flex !important;
    flex-direction: column;
    flex-shrink: 1;
    min-width: 0;
  }
  
  .logo-title {
    font-size: 0.875rem;
    /* اطمینان از نمایش عنوان روی موبایل‌های خیلی کوچک */
    display: block !important;
    color: #212529 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .logo-subtitle {
    font-size: 0.65rem;
    /* اطمینان از نمایش زیرعنوان روی موبایل‌های خیلی کوچک */
    display: block !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .logo-link {
    gap: 0.4rem;
  }
  
  .mobile-toggle {
    width: 35px;
    height: 35px;
  }
  
  .hamburger {
    width: 18px;
    height: 14px;
  }
  
  .mobile-nav {
    max-width: 100%;
  }

  .mobile-quick-actions {
    grid-template-columns: 1fr;
  }
  
  .mobile-nav-header {
    padding: 0.75rem;
    min-height: 55px;
  }
  
  .mobile-nav-header h3 {
    font-size: 1rem;
  }
  
  .mobile-close {
    width: 35px;
    height: 35px;
  }
  
  .mobile-nav-body {
    padding: 0.75rem;
  }
  
  .mobile-link {
    padding: 0.625rem 0.75rem;
    font-size: 0.9rem;
  }
  
  .mobile-link i {
    width: 18px;
    font-size: 1rem;
  }
  
  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
  
  .user-btn {
    padding: 0.375rem;
  }
  
  .action-btn {
    width: 35px;
    height: 35px;
  }
  
  .auth-buttons .btn {
    width: 35px;
    height: 35px;
  }
  
  .search-modal-content {
    width: 100%;
    margin: 0.5rem;
  }
  
  .search-header {
    padding: 0.625rem 0.75rem;
  }
  
  .search-body {
    padding: 0.75rem;
  }
  
  .search-input {
    font-size: 0.9rem;
    padding: 0.625rem;
  }
  
  .search-submit {
    padding: 0.625rem 0.75rem;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  
  /* Larger touch targets */
  .mobile-toggle,
  .action-btn,
  .user-btn,
  .auth-buttons .btn {
    min-width: 44px;
    min-height: 44px;
  }
  
  .mobile-link {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }
  
  .mobile-close {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .mobile-toggle:hover,
  .action-btn:hover,
  .user-btn:hover,
  .mobile-link:hover {
    transform: none;
  }
  
  /* Add active states for touch */
  .mobile-toggle:active,
  .action-btn:active,
  .user-btn:active,
  .mobile-link:active {
    transform: scale(0.95);
    background: rgba(13, 110, 253, 0.1);
  }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
  
  .modern-header {
    height: 50px;
  }
  
  .logo-text {
    display: flex !important;
    flex-direction: column;
    flex-shrink: 1;
    min-width: 0;
  }
  
  .logo-title {
    font-size: 0.875rem;
    /* اطمینان از نمایش عنوان در حالت افقی موبایل */
    display: block !important;
    color: #212529 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .logo-subtitle {
    font-size: 0.65rem;
    /* اطمینان از نمایش زیرعنوان در حالت افقی موبایل */
    display: block !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .logo-link {
    gap: 0.4rem;
  }
  
  .mobile-nav {
    max-width: 300px;
  }
  
  .mobile-nav-header {
    min-height: 50px;
    padding: 0.5rem 1rem;
  }
  
  .mobile-nav-body {
    padding: 0.5rem 1rem;
  }
  
  .mobile-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
  
  .mobile-auth {
    margin-top: 1rem;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  
  .logo-icon,
  .user-avatar,
  .mobile-toggle,
  .action-btn {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Dark Mode Mobile */
@media (prefers-color-scheme: dark) and (max-width: 1024px) {
  
  .mobile-nav {
    background: #1a1a1a;
    border-left-color: #333333;
  }
  
  .mobile-nav-header {
    background: #2d2d2d;
    border-bottom-color: #333333;
  }
  
  .mobile-nav-header h3 {
    color: #ffffff;
  }
  
  .mobile-close {
    background: var(--header-primary);
  }
  
  .mobile-link {
    color: #ffffff;
  }
  
  .mobile-link:hover {
    background: rgba(13, 110, 253, 0.2);
    color: var(--header-primary);
  }
  
  .mobile-auth {
    border-top-color: #333333;
  }

  .mobile-quick-action {
    background: rgba(13, 110, 253, 0.18);
    color: var(--header-primary);
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  
  .mobile-nav,
  .mobile-toggle,
  .hamburger span,
  .mobile-link,
  .action-btn,
  .user-btn {
    transition: none;
  }
  
  .mobile-nav.active {
    right: 0;
  }
  
  .hamburger span {
    transform: none;
  }
}

/* Print Styles */
@media print {
  
  .modern-header {
    position: static;
    box-shadow: none;
    border-bottom: 1px solid #000;
  }
  
  .mobile-toggle,
  .action-btn,
  .user-section {
    display: none;
  }
  
  .header-container {
    justify-content: center;
  }
  
  .logo-text {
    display: flex;
  }
}
