/* =============================================================================
   MOBILE OPTIMIZATION CSS - SMA Platform
   Професійна оптимізація мобільної версії
   ============================================================================= */

/* Базові мобільні налаштування */
@media (max-width: 768px) {
  /* Приховуємо непотрібні елементи на мобільних */
  #star-info,
  .quick-search-container,
  #current-time,
  .d-none.d-md-block {
    display: none !important;
  }
  
  /* Оптимізація топ-бару */
  .app-topbar-custom {
    padding: 0.5rem 1rem;
    min-height: 60px;
  }
  
  .app-topbar-custom .container-fluid {
    padding: 0;
  }
  
  /* Логотип та заголовок */
  .topbar-logo {
    flex: 1;
    min-width: 0;
  }
  
  .topbar-logo .fw-bold {
    display: none;
  }
  
  .topbar-logo .btn-link {
    padding: 0.25rem;
    margin-left: 0.5rem;
  }
  
  /* Центральний заголовок сторінки */
  .navbar-brand.mx-auto {
    display: none !important;
  }
  
  /* Права частина навігації */
  .d-flex.align-items-center.ms-auto {
    gap: 0.5rem;
  }
  
  /* Кнопки навігації */
  #onboarding-trigger,
  #faq-top-link,
  #support-topbar-btn {
    padding: 0.5rem;
    font-size: 1.1rem;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Перемикач теми */
  #theme-toggle {
    padding: 0.5rem;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Мобільна оптимізація профілю користувача */
@media (max-width: 768px) {
  /* Профіль дропдаун */
  .dropdown .nav-link {
    padding: 0.5rem;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Аватар користувача */
  .user-avatar-wrapper {
    width: 32px !important;
    height: 32px !important;
  }
  
  .user-avatar-wrapper img,
  .user-avatar-wrapper.default-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.9rem !important;
    line-height: 32px !important;
  }
  
  /* Дропдаун меню профілю */
  .dropdown-menu {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-top: 1px solid rgba(0,0,0,0.1) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    max-height: calc(100vh - 60px) !important;
    overflow-y: auto !important;
  }
  
  /* Мобільний заголовок профілю */
  .dropdown-item-text.text-center.d-md-none {
    padding: 1.5rem 1rem 1rem 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }
  
  .dropdown-item-text.text-center.d-md-none .user-avatar-wrapper {
    width: 64px !important;
    height: 64px !important;
    margin: 0 auto 1rem auto;
  }
  
  .dropdown-item-text.text-center.d-md-none .user-avatar-wrapper img,
  .dropdown-item-text.text-center.d-md-none .user-avatar-wrapper.default-avatar {
    width: 64px !important;
    height: 64px !important;
    font-size: 1.8rem !important;
    line-height: 64px !important;
  }
  
  /* Пункти меню профілю */
  .dropdown-item {
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
  
  .dropdown-item i {
    width: 20px;
    text-align: center;
    color: #6b7280;
  }
  
  /* Кнопка виходу */
  .dropdown-item.text-danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-bottom: none;
    margin-top: 0.5rem;
    border-radius: 0.5rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
  }
  
  .dropdown-item.text-danger i {
    color: #dc2626;
  }
  
  /* Реферальна програма */
  #referral-program-item {
    padding: 0;
  }
  
  .referral-trigger {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  }
  
  .referral-trigger i {
    color: #0284c7;
  }
  
  /* Розділювач */
  .dropdown-divider {
    margin: 0.5rem 0;
    border-color: rgba(0,0,0,0.1);
  }
}

/* Мобільна оптимізація сайдбару */
@media (max-width: 991.98px) {
  /* Сайдбар на мобільних - білий фон */
  #sidebar {
    width: 280px !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex !important;
    background: #ffffff !important;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    border-right: 2px solid #e5e7eb;
  }
  
  #sidebar.expanded {
    transform: translateX(0);
  }
  
  /* Темна тема */
  [data-bs-theme="dark"] #sidebar {
    background: #1e293b !important;
    border-right-color: #374151;
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }
  
  /* Кнопка закриття сайдбару */
  #sidebar .sidebar-header {
    justify-content: space-between;
    padding: 1rem;
    height: 70px;
    border-bottom: 2px solid #e5e7eb;
  }
  
  [data-bs-theme="dark"] #sidebar .sidebar-header {
    border-bottom-color: #374151;
  }
  
  #sidebar .sidebar-header #menu-toggle {
    font-size: 1.5rem;
    padding: 0.5rem;
    color: #1cb0f6;
    background: rgba(28, 176, 246, 0.1);
    border-radius: 0.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
  }
  
  [data-bs-theme="dark"] #sidebar .sidebar-header #menu-toggle {
    background: rgba(28, 176, 246, 0.15);
  }
  
  /* Заголовки сайдбару */
  #sidebar .sidebar-menu li.sidebar-heading {
    color: #6b7280;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 1rem 1.5rem 0.5rem 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: none;
    margin-bottom: 0.5rem;
  }
  
  [data-bs-theme="dark"] #sidebar .sidebar-menu li.sidebar-heading {
    color: #9ca3af;
  }
  
  /* Пункти меню сайдбару */
  #sidebar .sidebar-menu li a {
    padding: 0.875rem 1.5rem;
    margin: 0.25rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: #1f2937;
    background: transparent;
    border: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
  
  [data-bs-theme="dark"] #sidebar .sidebar-menu li a {
    color: #f1f5f9;
  }
  
  #sidebar .sidebar-menu li a:hover {
    background: #f3f4f6;
    transform: none;
  }
  
  [data-bs-theme="dark"] #sidebar .sidebar-menu li a:hover {
    background: #334155;
  }
  
  #sidebar .sidebar-menu li a.active {
    background: rgba(28, 176, 246, 0.1);
    color: #1cb0f6;
    font-weight: 600;
  }
  
  [data-bs-theme="dark"] #sidebar .sidebar-menu li a.active {
    background: rgba(59, 130, 246, 0.3);
  }
  
  #sidebar .sidebar-menu li a i.fa-fw,
  #sidebar .sidebar-menu li a .nav-emoji {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
  }
  
  #sidebar .sidebar-menu li a .menu-text {
    display: block !important;
    opacity: 1 !important;
    transform: none !important;
  }
  
  /* Кнопка виходу в сайдбарі */
  #sidebar .sidebar-menu li a.list-group-item-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    margin-top: 1rem;
    border-radius: 0.75rem;
  }
  
  #sidebar .sidebar-menu li a.list-group-item-danger:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
    transform: translateX(4px);
  }
  
  /* Оверлей для закриття сайдбару */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* Мобільна оптимізація контенту */
@media (max-width: 768px) {
  /* Основний контент */
  #main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
  
  .content-area {
    padding: 0.75rem !important;
  }
  
  /* Контейнери та картки */
  .container-fluid,
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .card {
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Кнопки */
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    border-radius: 0.75rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: 38px;
  }
  
  .btn-lg {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    min-height: 52px;
  }
  
  /* Форми */
  .form-control,
  .form-select {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 0.75rem;
    min-height: 44px;
    border: 2px solid #e5e7eb;
  }
  
  .form-control:focus,
  .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  /* Таблиці */
  .table-responsive {
    border-radius: 0.75rem;
    overflow: hidden;
  }
  
  .table {
    font-size: 0.9rem;
  }
  
  .table th,
  .table td {
    padding: 0.75rem 0.5rem;
  }
}

/* Мобільна оптимізація для дуже малих екранів */
@media (max-width: 480px) {
  .app-topbar-custom {
    padding: 0.5rem 0.75rem;
  }
  
  .content-area {
    padding: 0.5rem !important;
  }
  
  .container-fluid,
  .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .card-body {
    padding: 0.75rem;
  }
  
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.95rem;
  }
  
  .form-control,
  .form-select {
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
  }
}

/* Темна тема для мобільних */
@media (max-width: 768px) {
  [data-bs-theme="dark"] .dropdown-menu {
    background: #1f2937 !important;
    border-color: #374151 !important;
  }
  
  [data-bs-theme="dark"] .dropdown-item {
    color: #f9fafb !important;
    border-bottom-color: #374151 !important;
  }
  
  [data-bs-theme="dark"] .dropdown-item:hover {
    background: #374151 !important;
  }
  
  [data-bs-theme="dark"] .dropdown-item.text-danger {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%) !important;
    color: #fecaca !important;
  }
  
  [data-bs-theme="dark"] .dropdown-item-text.text-center.d-md-none {
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%) !important;
    border-bottom-color: #374151 !important;
  }
  
  [data-bs-theme="dark"] .referral-trigger {
    background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%) !important;
    color: #e0f2fe !important;
  }
  
  [data-bs-theme="dark"] .referral-trigger i {
    color: #38bdf8 !important;
  }
}

/* Анімації та переходи */
@media (max-width: 768px) {
  .dropdown-menu,
  .sidebar-overlay,
  #sidebar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .dropdown-item,
  #sidebar .sidebar-menu li a {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Плавне з'явлення дропдауну */
  .dropdown-menu.show {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Плавне відкриття сайдбару */
  #sidebar.expanded {
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  @keyframes slideInLeft {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(0);
    }
  }
}

/* Утиліти для мобільних */
@media (max-width: 768px) {
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-visible {
    display: block !important;
  }
  
  .mobile-text-center {
    text-align: center !important;
  }
  
  .mobile-full-width {
    width: 100% !important;
  }
  
  .mobile-margin-bottom {
    margin-bottom: 1rem !important;
  }
  
  .mobile-padding {
    padding: 1rem !important;
  }
}
