/* ============================================
   responsive-override.css
   Полная адаптация под все устройства
   Загружать ПОСЛЕ всех остальных CSS
   ============================================ */

/* ============================================
   ПРОИЗВОДИТЕЛЬНОСТЬ
   Отключаем тяжелые эффекты на мобильных
   ============================================ */
@media (max-width: 1023px) {
  .app-header,
  .main-sections,
  .user-menu-dropdown,
  .card,
  .profile-card,
  .tariffs-modal-content,
  .news-modal-card,
  .modal,
  .login-card,
  [class*="modal-"],
  [class*="-modal-"] {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .app-header::before,
  .brand-logo::before,
  .card-glow,
  .card-glow::after,
  [class*="glow"],
  [class*="shine"] {
    display: none !important;
  }

  .brand-logo,
  .btn,
  .stat-card,
  .house-card,
  .tariff-card,
  .news-card,
  .main-section-btn,
  .dashboard-card {
    box-shadow: none !important;
  }

  .app-header,
  .main-section-content {
    box-shadow: 0 1px 4px rgba(0,0,0,0.08) !important;
  }

  .user-menu-btn:hover {
    transform: none !important;
  }

  .user-menu-container:hover .user-menu-dropdown {
    display: none !important;
  }
  .user-menu-container .user-menu-dropdown.show {
    display: block !important;
  }

  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Отключаем тяжелые CSS-анимации */
  .app-header,
  .main-section-content,
  .house-card,
  .stat-card,
  .dashboard-card,
  .tariff-card,
  .news-card,
  .organizations-grid > *,
  .house-card,
  [class*="card"],
  [class*="stagger"],
  [class*="fade"],
  [class*="anim"] {
    animation: none !important;
  }

  [class*="shimmer"],
  [class*="gradient"],
  [class*="glow"],
  [class*="orb"],
  [class*="pulse"],
  [class*="float"],
  [class*="spin"],
  [class*="shake"],
  [class*="rotate"] {
    animation: none !important;
  }

  .login-card,
  .login-header,
  .login-form,
  .login-bg-orbs span,
  .login-bg-orbs::before,
  .login-bg-orbs::after {
    animation: none !important;
  }

  /* Заменяем transition: all на только opacity/transform для экономии */
  .main-section-btn,
  .btn,
  .user-menu-btn,
  .user-menu-item,
  .tariff-card,
  .news-card,
  .stat-card,
  .dashboard-card,
  .house-card,
  .sub-tab-btn,
  .admin-tab-btn,
  .meeting-tab-btn,
  .format-btn,
  [class*="tab-btn"],
  [class*="card-"] {
    transition: opacity 0.15s ease, transform 0.15s ease !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;
  }
}

/* ============================================
   ТАБЛИЦЫ → КАРТОЧКИ НА МОБИЛЬНЫХ
   ============================================ */
@media (max-width: 767px) {
  .table-container,
  .oss-meetings-table-scroll,
  .meetings-table-container {
    overflow-x: visible !important;
  }

  .data-table:not(.keep-table),
  .house-meetings-table:not(.keep-table),
  .oss-meetings-table:not(.keep-table) {
    min-width: auto !important;
    display: block;
  }

  .data-table:not(.keep-table) thead,
  .house-meetings-table:not(.keep-table) thead,
  .oss-meetings-table:not(.keep-table) thead {
    display: none;
  }

  .data-table:not(.keep-table) tbody,
  .house-meetings-table:not(.keep-table) tbody,
  .oss-meetings-table:not(.keep-table) tbody {
    display: block;
  }

  .data-table:not(.keep-table) tbody tr,
  .house-meetings-table:not(.keep-table) tbody tr,
  .oss-meetings-table:not(.keep-table) tbody tr {
    display: block;
    padding: 14px;
    margin-bottom: 12px;
    background: var(--bg-glass-strong, #131825);
    border: 1px solid var(--border, #1f2a44);
    border-radius: 12px;
  }

  .data-table:not(.keep-table) tbody tr td,
  .house-meetings-table:not(.keep-table) tbody tr td,
  .oss-meetings-table:not(.keep-table) tbody tr td {
    display: flex;
    padding: 6px 0;
    border: none;
    background: transparent;
    font-size: 13px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    text-align: right;
    min-height: 32px;
  }

  .data-table:not(.keep-table) tbody tr td:empty {
    display: none;
  }

  .data-table:not(.keep-table) tbody tr td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-2, #8b8fa3);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: left;
    min-width: 80px;
  }

  .data-table:not(.keep-table) tbody tr td:first-child {
    padding-top: 0;
  }

  .data-table:not(.keep-table) tbody tr td:last-child {
    padding-bottom: 0;
    border-bottom: none;
  }

  .data-table:not(.keep-table) .action-btns,
  .data-table:not(.keep-table) td:has(.btn),
  .data-table:not(.keep-table) td[style*="width: 140px"],
  .data-table:not(.keep-table) td[style*="width: 180px"],
  .data-table:not(.keep-table) td:last-child {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  .data-table:not(.keep-table) .action-btns .btn,
  .data-table:not(.keep-table) td .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* ============================================
   МОДАЛЬНЫЕ ОКНА — ПОЛНОЭКРАННЫЕ НА МОБИЛЬНЫХ
   ============================================ */
@media (max-width: 640px) {
  .tariffs-modal-content,
  .news-modal-card,
  .modal,
  [class*="modal-content"],
  [class*="-modal-content"] {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0 !important;
    padding: 16px !important;
    overflow-y: auto;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
  }

  .tariffs-modal-overlay,
  .news-modal-overlay,
  [class*="modal-overlay"] {
    padding: 0 !important;
    align-items: flex-end;
  }

  .tariffs-modal-close,
  .news-modal-close-btn,
  .close-btn,
  [class*="modal-close"] {
    top: 10px !important;
    right: 10px !important;
    width: 36px;
    height: 36px;
    font-size: 22px;
    z-index: 10;
  }
}

/* ============================================
   ДАШБОРД — АДАПТИВ
   ============================================ */
@media (max-width: 767px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  .dashboard-charts-row {
    flex-direction: column !important;
    gap: 12px;
  }

  .dashboard-chart-card {
    width: 100%;
  }

  .dashboard-chart-card__body canvas {
    max-height: 220px;
  }

  .dashboard-date-filter {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .dashboard-date-filter label {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .dashboard-date-filter label span {
    min-width: 30px;
  }

  .dashboard-date-filter input[type="date"] {
    flex: 1;
  }

  .dashboard-section.card {
    padding: 12px;
  }
}

/* ============================================
   ТАРИФЫ — АДАПТИВ
   ============================================ */
@media (max-width: 767px) {
  .tariffs-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .tariff-card {
    padding: 20px 16px;
  }

  .tariffs-period-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .period-buttons {
    flex-wrap: wrap;
  }

  .tariff-period-btn {
    flex: 1;
    text-align: center;
  }
}

/* ============================================
   ЗАГОЛОВОК — АДАПТИВ
   ============================================ */
@media (max-width: 768px) {
  .container {
    padding: 8px;
  }

  .app-header {
    padding: 10px 12px !important;
    margin-bottom: 10px !important;
    border-radius: 10px !important;
    top: 6px !important;
  }

  .brand-logo {
    width: 34px !important;
    height: 34px !important;
    font-size: 14px !important;
    flex-shrink: 0;
  }

  .brand-title {
    font-size: 13px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }

  .brand-subtitle {
    display: none;
  }

  .header-user {
    gap: 6px;
    flex-shrink: 0;
  }

  .user-org {
    display: none !important;
  }

  .user-menu-btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 400px) {
  .brand-title {
    max-width: 100px;
    font-size: 12px !important;
  }

  .brand-logo {
    width: 30px !important;
    height: 30px !important;
  }
}

/* ============================================
   ПЛАНШЕТЫ (769px — 1023px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1023px) {
  .container {
    padding: 14px;
  }

  .app-header {
    padding: 12px 16px !important;
  }

  .header-brand {
    gap: 10px;
  }

  .brand-title {
    font-size: 15px;
    max-width: 300px;
  }

  .main-sections {
    gap: 4px;
    padding: 6px;
  }

  .main-section-btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .dashboard-stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px;
  }

  .dashboard-charts-row {
    flex-direction: row !important;
    gap: 14px;
  }

  .tariffs-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* ============================================
   РАЗДЕЛЫ — СЕКЦИИ НА МОБИЛЬНЫХ
   ============================================ */
@media (max-width: 767px) {
  .main-section-content {
    padding: 12px !important;
    border-radius: 10px !important;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .section-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .section-title {
    font-size: 18px !important;
  }

  .section-subtitle {
    font-size: 13px !important;
  }

  .section-title-icon {
    font-size: 16px;
  }

  .section-header .btn {
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .form-control,
  .form-input,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="date"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
    padding: 10px 12px !important;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .btn-primary,
  .btn-secondary,
  .btn-danger {
    min-height: 44px;
  }
}

/* ============================================
   СТРАНИЦА ЛОГИНА
   ============================================ */
@media (max-width: 767px) {
  .login-page {
    padding: 16px;
  }

  .login-card {
    padding: 24px 20px !important;
    border-radius: 16px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .login-header {
    margin-bottom: 20px;
  }

  .login-brand {
    margin-bottom: 12px;
  }

  .login-brand-icon {
    width: 40px;
    height: 40px;
  }

  .login-brand-text {
    font-size: 20px;
  }

  .login-title {
    font-size: 22px;
  }

  .login-subtitle {
    font-size: 13px;
  }

  .login-form-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .btn-login {
    min-height: 48px;
    font-size: 15px;
  }

  .btn-tariffs {
    min-height: 44px;
  }

  .login-bg-orbs {
    display: none;
  }
}

/* ============================================
   НОВОСТИ
   ============================================ */
@media (max-width: 767px) {
  .news-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .news-card {
    padding: 14px;
  }

  .news-card h3 {
    font-size: 15px;
  }

  .news-comment-form {
    flex-direction: column;
    gap: 8px;
  }

  .news-comment-form textarea {
    width: 100%;
  }

  .news-comment-form .btn {
    width: 100%;
  }
}

/* ============================================
   КАРТОЧКИ ДОМОВ
   ============================================ */
@media (max-width: 767px) {
  .houses-list .house-card,
  [class*="house-card"],
  [class*="HouseCard"] {
    flex-direction: column !important;
    padding: 14px !important;
  }

  .house-card .house-card__info {
    flex-direction: column !important;
    gap: 6px;
  }

  .house-card .house-card__actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .house-card .house-card__actions .btn {
    flex: 1;
    min-width: 0;
    text-align: center;
  }
}

/* ============================================
   ОРГАНИЗАЦИИ
   ============================================ */
@media (max-width: 767px) {
  .organizations-grid {
    grid-template-columns: 1fr !important;
  }

  .organization-card {
    padding: 14px;
  }
}

/* ============================================
   TOAST / УВЕДОМЛЕНИЯ
   ============================================ */
@media (max-width: 480px) {
  .notification-container {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .notification {
    min-width: 0;
    max-width: 100%;
    padding: 12px 14px;
    font-size: 13px;
  }
}

/* ============================================
   ФИКСЫ ДЛЯ SAFARI iOS
   ============================================ */
@supports (-webkit-touch-callout: none) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ============================================
   ВСПОМОГАТЕЛЬНЫЕ КЛАССЫ
   ============================================ */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }
}
