/* ====================================
   АДАПТИВНЫЕ СТИЛИ
   MLM CRM v2.0
   Mobile-First подход
   ==================================== */

/* ========================================
   TABLET (768px и меньше)
   ======================================== */
@media (max-width: 768px) {
  /* Навигация */
  .nav-rail {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 1000;
    transition: transform 0.3s ease;
  }
  
  .nav-rail.nav-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  /* Header */
  .main-header {
    padding: 0 var(--spacing-md);
  }
  
  .header-center {
    display: none;
  }
  
  .header-left,
  .header-right {
    min-width: auto;
  }
  
  .user-name {
    display: none;
  }
  
  /* Контент */
  .page-content {
    padding: var(--spacing-md);
  }
  
  /* Dashboard */
  .dashboard-widgets {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
  }
  
  .widget {
    padding: var(--spacing-md);
  }
  
  .widget-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .widget-value {
    font-size: var(--font-size-xl);
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  /* Kanban */
  .kanban-board {
    padding: var(--spacing-sm);
    gap: var(--spacing-md);
  }
  
  .kanban-column {
    flex: 0 0 280px;
    min-width: 280px;
  }
  
  /* Таблицы */
  .table-container {
    overflow-x: auto;
  }
  
  .data-table {
    min-width: 800px;
  }
  
  /* Фильтры */
  .filters-grid {
    grid-template-columns: 1fr;
  }
  
  /* Формы */
  .form-row {
    grid-template-columns: 1fr;
  }
  
  /* Модалки */
  .modal-container {
    width: 95%;
    max-height: 95vh;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-md);
  }
  
  /* Уведомления */
  .notification-container {
    left: 20px;
    right: 20px;
  }
  
  .notification {
    min-width: auto;
    max-width: none;
  }
}

/* ========================================
   MOBILE (480px и меньше)
   ======================================== */
@media (max-width: 480px) {
  /* Шрифты */
  html {
    font-size: 14px;
  }
  
  /* Dashboard */
  .dashboard-widgets {
    grid-template-columns: 1fr;
  }
  
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-md);
  }
  
  .dashboard-header h2 {
    font-size: var(--font-size-xl);
  }
  
  .dashboard-actions {
    flex-wrap: wrap;
  }
  
  /* Страницы */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-md);
  }
  
  .page-header h2 {
    font-size: var(--font-size-xl);
  }
  
  .page-actions {
    flex-wrap: wrap;
  }
  
  .page-actions .btn {
    flex: 1;
    min-width: 140px;
  }
  
  /* Kanban */
  .kanban-column {
    flex: 0 0 260px;
    min-width: 260px;
  }
  
  .kanban-card-header {
    flex-direction: column;
    gap: 4px;
  }
  
  /* Задачи */
  .task-card {
    padding: var(--spacing-md);
  }
  
  .task-card-title {
    font-size: var(--font-size-sm);
  }
  
  .task-card-meta {
    flex-direction: column;
    gap: 4px;
  }
  
  /* Таблицы */
  .data-table {
    font-size: var(--font-size-xs);
  }
  
  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }
  
  /* Auth страницы */
  .auth-container {
    padding: var(--spacing-md);
  }
  
  .auth-card {
    border-radius: var(--radius);
  }
  
  .auth-header,
  .auth-form,
  .auth-footer {
    padding: var(--spacing-lg);
  }
  
  .auth-logo {
    font-size: 36px;
  }
  
  .auth-title {
    font-size: var(--font-size-xl);
  }
  
  /* Кнопки */
  .btn {
    padding: 10px 16px;
    font-size: var(--font-size-sm);
  }
  
  .btn-lg {
    padding: 12px 20px;
  }
  
  .btn-sm {
    padding: 6px 10px;
    font-size: var(--font-size-xs);
  }
  
  /* Tooltip */
  .tooltip {
    max-width: 280px;
    font-size: var(--font-size-xs);
  }
  
  /* Скрытие второстепенных элементов */
  .hide-mobile {
    display: none !important;
  }
}

/* ========================================
   SMALL MOBILE (360px и меньше)
   ======================================== */
@media (max-width: 360px) {
  html {
    font-size: 13px;
  }
  
  /* Dashboard */
  .widget {
    flex-direction: column;
    text-align: center;
  }
  
  .widget-icon {
    margin-bottom: var(--spacing-xs);
  }
  
  /* Kanban */
  .kanban-column {
    flex: 0 0 240px;
    min-width: 240px;
  }
  
  /* Таблицы */
  .data-table {
    min-width: 600px;
  }
}

/* ========================================
   DESKTOP (1024px и больше)
   ======================================== */
@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   LARGE DESKTOP (1440px и больше)
   ======================================== */
@media (min-width: 1440px) {
  .dashboard-widgets {
    max-width: 1400px;
    margin: 0 auto var(--spacing-xl);
  }
  
  .dashboard-grid {
    max-width: 1400px;
    margin: 0 auto;
  }
  
  .clients-page,
  .leads-page,
  .planning-page {
    max-width: 1600px;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  /* Скрытие элементов */
  .nav-rail,
  .main-header,
  .page-actions,
  .filters-panel,
  .table-controls,
  .pagination,
  .btn,
  button,
  .modal-overlay,
  .tooltip,
  .notification-container {
    display: none !important;
  }
  
  /* Основные стили */
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }
  
  .main-content {
    width: 100%;
  }
  
  .page-content {
    padding: 0;
  }
  
  /* Таблицы */
  .table-container {
    overflow: visible;
  }
  
  .data-table {
    width: 100%;
    font-size: 10pt;
  }
  
  .data-table th,
  .data-table td {
    border: 1px solid #000;
    padding: 6px;
  }
  
  /* Карточки */
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
  
  /* Ссылки */
  a {
    color: black;
    text-decoration: none;
  }
  
  /* Пустые состояния */
  .empty-state {
    color: #666;
  }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .nav-rail.nav-open {
    width: 200px;
  }
  
  .kanban-board {
    min-height: calc(100vh - 120px);
  }
  
  .kanban-column {
    max-height: calc(100vh - 140px);
  }
}

/* ========================================
   TOUCH DEVICES
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  /* Увеличение зон клика */
  .btn {
    min-height: 44px;
  }
  
  .nav-item {
    min-height: 48px;
  }
  
  /* Убираем hover эффекты */
  .kanban-card:hover {
    transform: none;
  }
  
  .widget:hover {
    transform: none;
  }
  
  /* Улучшение скролла */
  .kanban-board {
    -webkit-overflow-scrolling: touch;
  }
  
  .kanban-cards {
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   HIGH CONTRAST
   ======================================== */
@media (prefers-contrast: high) {
  :root {
    --border: rgba(0, 0, 0, 0.3);
    --border-light: rgba(0, 0, 0, 0.2);
  }
  
  [data-theme="dark"] {
    --border: rgba(255, 255, 255, 0.3);
    --border-light: rgba(255, 255, 255, 0.2);
  }
  
  .btn {
    border: 2px solid currentColor;
  }
}

/* ========================================
   IMPROVED MOBILE STYLES v2.0
   ======================================== */

/* Mobile Navigation - Bottom Bar */
@media (max-width: 768px) {
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    padding: 8px;
    z-index: 1000;
    flex-direction: row;
    justify-content: space-around;
  }
  
  .nav-item {
    flex-direction: column;
    padding: 8px 12px;
    gap: 4px;
  }
  
  .nav-item i {
    font-size: 20px;
  }
  
  .nav-item span {
    font-size: 11px;
  }
  
  .main-content {
    padding-bottom: 70px;
  }
  
  /* Dashboard on mobile */
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  /* Hide table columns on mobile */
  .data-table th:nth-child(6),
  .data-table td:nth-child(6),
  .data-table th:nth-child(7),
  .data-table td:nth-child(7) {
    display: none;
  }
  
  /* Kanban scrollable */
  .kanban-board {
    overflow-x: auto;
  }
  
  .kanban-column {
    min-width: 260px;
  }
  
  /* Modal full screen on mobile */
  .modal-content {
    max-height: 90vh;
    margin: 20px;
  }
}

/* Touch-friendly */
@media (hover: none) and (pointer: coarse) {
  .btn, .btn-icon, .nav-item {
    min-height: 44px;
  }
}
