/**
 * Multi-Chat View Styles - Versione Redesigned
 * Modale scelta numero chat + Layout grid
 */

/* ═══════════════════════════════════════════════════════════
   MODALE SCELTA CHAT
   ═══════════════════════════════════════════════════════════ */

.multichat-choice-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
}

.multichat-choice-modal.active {
  display: flex;
}

.multichat-choice-content {
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #00f2ff;
  border-radius: 12px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 0 40px rgba(0, 242, 255, 0.3);
  animation: modalOpen 0.3s ease;
}

@keyframes modalOpen {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.multichat-choice-content h2 {
  color: #00f2ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  margin-bottom: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(0, 242, 255, 0.3);
  padding-bottom: 15px;
}

.chat-type-selection {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
}

.chat-type-btn {
  flex: 1;
  padding: 15px;
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.3);
  border-radius: 8px;
  color: #00f2ff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.3s;
  text-align: center;
}

.chat-type-btn:hover {
  background: rgba(0, 242, 255, 0.15);
  border-color: #00f2ff;
}

.chat-type-btn.selected {
  background: rgba(0, 242, 255, 0.2);
  border-color: #00f2ff;
  box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

.chat-type-btn.premium {
  border-color: #ffd700;
  color: #ffd700;
}

.chat-type-btn.premium:hover {
  background: rgba(255, 215, 0, 0.15);
}

.chat-type-btn.premium.selected {
  background: rgba(255, 215, 0, 0.2);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.chat-count-selector {
  margin-bottom: 25px;
}

.chat-count-selector label {
  display: block;
  color: #00f2ff;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.chat-count-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.count-btn {
  width: 50px;
  height: 50px;
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.3);
  border-radius: 8px;
  color: #00f2ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
}

.count-btn:hover {
  background: rgba(0, 242, 255, 0.15);
  border-color: #00f2ff;
}

.count-btn.selected {
  background: rgba(0, 255, 65, 0.2);
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
}

.count-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.device-info-box {
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.2);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 20px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
}

.device-info-box strong {
  color: #00f2ff;
}

/* Sector Selectors */
.sector-selectors-container {
  width: 100%;
}

.sector-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px;
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.2);
  border-radius: 4px;
}

.sector-selector-row .chat-num {
  color: #00f2ff;
  font-size: 0.75rem;
  font-family: 'Orbitron', sans-serif;
  min-width: 50px;
}

.sector-selector-row .sector-input,
.sector-selector-row .cell-input {
  width: 50px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 242, 255, 0.3);
  color: #00f2ff;
  padding: 6px 8px;
  border-radius: 4px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  outline: none;
  text-align: center;
}

.sector-selector-row .sector-input:focus,
.sector-selector-row .cell-input:focus {
  border-color: #00f2ff;
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

.sector-selector-row .sector-input::placeholder,
.sector-selector-row .cell-input::placeholder {
  color: rgba(0, 242, 255, 0.4);
}

.random-sector-btn {
  background: rgba(0, 242, 255, 0.1);
  border: 1px solid rgba(0, 242, 255, 0.3);
  color: #00f2ff;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: 0.3s;
}

.random-sector-btn:hover {
  background: rgba(0, 242, 255, 0.2);
  border-color: #00f2ff;
}

.random-all-btn:hover {
  background: rgba(0, 242, 255, 0.2) !important;
  border-color: #00f2ff !important;
}

.multichat-choice-actions {
  display: flex;
  gap: 15px;
}

.multichat-choice-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.3s;
}

.multichat-confirm-btn {
  background: linear-gradient(135deg, #00f2ff, #0066ff);
  border: none;
  color: #000;
  font-weight: bold;
}

.multichat-confirm-btn:hover {
  background: linear-gradient(135deg, #00ff41, #00cc33);
  transform: scale(1.02);
}

.multichat-cancel-btn {
  background: transparent;
  border: 1px solid #ff003c;
  color: #ff003c;
}

.multichat-cancel-btn:hover {
  background: rgba(255, 0, 60, 0.1);
}

/* ═══════════════════════════════════════════════════════════
   CONTAINER PRINCIPALE MULTI-CHAT
   ═══════════════════════════════════════════════════════════ */

.multi-chat-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.98);
  z-index: 100;
  padding: 90px 20px 20px 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

.multi-chat-container.active {
  display: grid;
  gap: 15px;
  align-items: center;
  justify-items: center;
  justify-content: center;
}

/* Layout dinamico basato su numero chat */
.multi-chat-container[data-count="1"] {
  grid-template-columns: 1fr;
  max-width: 800px;
  margin: 0 auto;
}

.multi-chat-container[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  max-width: 1200px;
  margin: 0 auto;
}

.multi-chat-container[data-count="3"] {
  grid-template-columns: 1fr 1fr 1fr;
  max-width: 1400px;
  margin: 0 auto;
}

.multi-chat-container[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-width: 1200px;
  margin: 0 auto;
}

/* Chat Window individuale - ora contiene modal-content cyberpunk-card */
.chat-window {
  animation: chatWindowOpen 0.4s ease;
}

.chat-window.closing {
  animation: chatWindowClose 0.3s ease forwards;
}

@keyframes chatWindowOpen {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes chatWindowClose {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* Messaggio individuale nelle chat multi-chat */
.chat-window-message {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-window-message.sent {
  background: rgba(0, 255, 65, 0.15);
  border: 1px solid rgba(0, 255, 65, 0.3);
  margin-left: 20%;
}

.chat-window-message.received {
  background: rgba(0, 242, 255, 0.1);
  border: 1px solid rgba(0, 242, 255, 0.2);
  margin-right: 20%;
}

.chat-window-message .message-sender {
  color: #00f2ff;
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 4px;
  display: block;
}

.chat-window-message .message-text {
  color: #fff;
  word-wrap: break-word;
}

.chat-window-message .message-time {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.65rem;
  margin-top: 4px;
  display: block;
}

/* Limit indicator */
.chat-limit-indicator {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #00f2ff;
  border-radius: 6px;
  padding: 8px 15px;
  color: #00f2ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  z-index: 150;
}

.chat-limit-indicator.premium {
  border-color: #ffd700;
  color: #ffd700;
}

.chat-limit-indicator.warning {
  border-color: #ff6600;
  color: #ff6600;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Pulsante chiudi tutto - Fixed, sempre visibile */
.multi-chat-close-all-container {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  pointer-events: auto;
}

.close-all-btn {
  background: rgba(255, 0, 60, 0.3);
  border: 1px solid #ff003c;
  color: #ff003c;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 1px;
  transition: 0.3s;
}

.close-all-btn:hover {
  background: rgba(255, 0, 60, 0.5);
  box-shadow: 0 0 10px rgba(255, 0, 60, 0.3);
}

/* Rimuovi vecchio footer */
.multi-chat-footer {
  display: none;
}

/* Multi-Chat Access Button */
.multi-chat-access-btn {
  transition: 0.3s;
}

.multi-chat-access-btn:hover {
  background: rgba(0, 242, 255, 0.3) !important;
  transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE MULTI-CHAT SELECTOR & RESPONSIVE GRID
   ═══════════════════════════════════════════════════════════ */

.mobile-chat-selector-container {
  display: none;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 15px auto;
  position: relative;
  z-index: 250;
}

.mobile-chat-selector {
  width: 100%;
  padding: 12px;
  background: rgba(0, 0, 0, 0.92);
  border: 2px solid #00f2ff;
  border-radius: 8px;
  color: #00f2ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='%2300f2ff' d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 24px;
  font-weight: bold;
  letter-spacing: 1px;
}

.mobile-chat-selector option {
  background: #050505;
  color: #00f2ff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  padding: 10px;
}

@media (max-width: 768px) {
  /* Mostra la select su mobile */
  .mobile-chat-selector-container {
    display: block;
  }

  /* Forza il grid layout a 1 colonna a prescindere dal numero di chat */
  .multi-chat-container[data-count] {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    display: flex !important;
    flex-direction: column !important;
    padding-top: 100px; /* Spazio per top bar e chiudi tutto */
  }

  /* Nascondi tutte le chat tranne quella attiva */
  .chat-window {
    display: none !important;
    width: 100%;
  }

  .chat-window.mobile-active {
    display: block !important;
  }
}