/* ════════════════════════════════════════════════════════════════════
   TypeArena — MODALS & DIALOGS BEAUTIFULLY v5
   Красивые модальные окна, диалоги, попапы, красивый интерфейс
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* ─────── MODAL BASE ─────── */
  .modal-base {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-end;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
  }

  .modal-base.closing {
    animation: fadeOut 0.3s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
  }

  .modal-content {
    width: 100%;
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    padding: 16px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .modal-content.closing {
    animation: slideDown 0.3s ease;
  }

  @keyframes slideDown {
    from {
      transform: translateY(0);
      opacity: 1;
    }
    to {
      transform: translateY(100%);
      opacity: 0;
    }
  }

  .modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 8px;
  }

  .modal-title {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text);
    flex: 1;
  }

  .modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg2);
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }

  .modal-close:active {
    transform: scale(0.9);
  }

  .modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .modal-footer {
    display: flex;
    gap: 8px;
    margin-top: 16px;
  }

  .modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
  }

  .modal-btn.primary {
    background: linear-gradient(135deg, var(--accent), rgba(88, 166, 255, 0.6));
    color: white;
  }

  .modal-btn.secondary {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid var(--border);
  }

  .modal-btn:active {
    transform: scale(0.98);
  }

  /* ─────── CONFIRMATION DIALOG ─────── */
  .confirm-dialog {
    text-align: center;
  }

  .confirm-icon {
    font-size: 3rem;
    margin-bottom: 12px;
  }

  .confirm-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
  }

  .confirm-message {
    font-size: 0.9rem;
    color: var(--text2);
    line-height: 1.5;
    margin-bottom: 16px;
  }

  /* ─────── ALERT DIALOG ─────── */
  .alert-dialog {
    text-align: center;
  }

  .alert-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
  }

  .alert-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
  }

  .alert-message {
    font-size: 0.85rem;
    color: var(--text2);
    line-height: 1.5;
  }

  /* ─────── INFO POPUP ─────── */
  .info-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 16px;
    max-width: 280px;
    z-index: 1001;
    animation: popupEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes popupEnter {
    from {
      opacity: 0;
      transform: translate(-50%, -50%) scale(0.8);
    }
    to {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }
  }

  .popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
  }

  /* ─────── BOTTOM SHEET ─────── */
  .bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-radius: 16px 16px 0 0;
    padding: 16px;
    max-height: 80vh;
    z-index: 500;
    animation: sheetSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes sheetSlideUp {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .sheet-drag-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }

  /* ─────── DROPDOWN MENU ─────── */
  .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    z-index: 200;
    min-width: 160px;
    animation: dropdownSlideIn 0.2s ease;
  }

  @keyframes dropdownSlideIn {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .dropdown-item {
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    width: 100%;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
  }

  .dropdown-item:hover {
    background: var(--bg3);
  }

  .dropdown-item.danger {
    color: #ff6464;
  }

  /* ─────── TOOLTIP IMPROVED ─────── */
  .tooltip {
    position: relative;
  }

  .tooltip-content {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg3);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
  }

  .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--bg3);
  }

  .tooltip:hover .tooltip-content {
    opacity: 1;
  }

  /* ─────── CONTEXT MENU ─────── */
  .context-menu {
    position: fixed;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    z-index: 300;
    min-width: 150px;
    animation: dropdownSlideIn 0.2s ease;
  }

  .context-item {
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    width: 100%;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
  }

  .context-item:hover {
    background: var(--bg3);
  }

  /* ─────── LOADING DIALOG ─────── */
  .loading-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
  }

  .loading-dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .loading-spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(88, 166, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  .loading-text {
    font-size: 0.95rem;
    color: var(--text);
    font-weight: 600;
  }

  /* ─────── SNACKBAR ─────── */
  .snackbar {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 150;
    animation: slideUp 0.3s ease;
  }

  .snackbar-message {
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
  }

  .snackbar-action {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
  }

  /* ─────── BANNER ─────── */
  .banner {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(167, 113, 247, 0.1));
    border: 2px solid rgba(88, 166, 255, 0.2);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .banner-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .banner-content {
    flex: 1;
  }

  .banner-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 2px;
  }

  .banner-desc {
    font-size: 0.8rem;
    color: var(--text2);
    line-height: 1.4;
  }

  .banner.warning {
    background: linear-gradient(135deg, rgba(255, 200, 50, 0.15), rgba(255, 150, 50, 0.05));
    border-color: rgba(255, 200, 50, 0.3);
  }

  .banner.error {
    background: linear-gradient(135deg, rgba(255, 100, 100, 0.15), rgba(255, 100, 100, 0.05));
    border-color: rgba(255, 100, 100, 0.3);
  }

  .banner.success {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(74, 222, 128, 0.05));
    border-color: rgba(74, 222, 128, 0.3);
  }

  /* ─────── ANIMATIONS FOR LOW GRAPHICS ─────── */
  body[data-graphics="low"] .modal-content,
  body[data-graphics="low"] .info-popup,
  body[data-graphics="low"] .bottom-sheet {
    animation: none;
    opacity: 1;
    transform: none;
  }

  body[data-graphics="low"] .modal-base {
    animation: none;
    opacity: 1;
    backdrop-filter: none;
  }

  body[data-graphics="low"] .dropdown-menu,
  body[data-graphics="low"] .context-menu {
    animation: none;
    opacity: 1;
    transform: none;
  }

  /* ─────── HIGH GRAPHICS ENHANCEMENTS ─────── */
  body[data-graphics="high"] .modal-base {
    backdrop-filter: blur(12px);
  }

  body[data-graphics="high"] .info-popup {
    box-shadow: 0 8px 32px rgba(88, 166, 255, 0.3);
  }

  body[data-graphics="high"] .modal-content {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  }

  /* ─────── DIALOG RESPONSIVE ─────── */
  @media (max-width: 480px) {
    .modal-content {
      border-radius: 16px 16px 0 0;
    }

    .info-popup {
      max-width: 90%;
    }

    .dropdown-menu {
      left: 0;
      right: 0;
      max-width: 100%;
    }
  }
}
