/* ============================================
   DEVSVILUPPO TEAMS v2 - Design System
   Dark Premium / Industrial Minimal
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg-void: #0a0a0c;
  --bg-surface: #111115;
  --bg-raised: #18181e;
  --bg-overlay: #1f1f28;
  --bg-hover: #25252f;
  --bg-active: #2c2c3a;

  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --border-active: rgba(255,255,255,0.2);

  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --text-accent: #a8a8ff;

  --accent: #7c7cff;
  --accent-glow: rgba(124, 124, 255, 0.3);
  --accent-dim: rgba(124, 124, 255, 0.15);
  --accent-hover: #9090ff;

  --green: #4dff91;
  --green-dim: rgba(77, 255, 145, 0.15);
  --yellow: #ffcc4d;
  --yellow-dim: rgba(255, 204, 77, 0.15);
  --red: #ff4d6d;
  --red-dim: rgba(255, 77, 109, 0.15);
  --orange: #ff8c4d;

  --sidebar-w: 280px;
  --thread-w: 340px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 24px rgba(124, 124, 255, 0.2);

  --font: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

/* ==================== LAYOUT ==================== */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* ==================== AUTH SCREEN ==================== */
#auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-void);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

#auth-screen::before {
  content: '';
  position: fixed;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124, 124, 255, 0.08) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), 0 0 80px rgba(124, 124, 255, 0.05);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.auth-logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.auth-logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder { color: var(--text-muted); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  margin-top: 8px;
  letter-spacing: 0.2px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary .btn-loader {
  display: none;
}

.btn-primary.loading .btn-loader {
  display: inline-block;
}

.btn-primary.loading .btn-text {
  display: none;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: var(--transition-slow);
  z-index: 100;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
}

.sidebar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 16px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Sezioni sidebar */
.sidebar-section {
  padding: 12px 8px 4px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

/* Lista conversazioni */
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }
.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar img, .avatar .avatar-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.avatar-placeholder.group {
  border-radius: 12px;
  font-size: 16px;
}

.status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.status-dot.online { background: var(--green); }
.status-dot.away { background: var(--yellow); }
.status-dot.busy { background: var(--red); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.invisible { background: transparent; border-color: var(--text-muted); }

.conv-info { flex: 1; min-width: 0; }

.conv-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.conv-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.unread-badge {
  min-width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  padding: 0 4px;
}

/* ==================== PROFILO UTENTE ==================== */
.user-profile {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.user-profile:hover { background: var(--bg-hover); }

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== AREA CHAT ==================== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-void);
  position: relative;
}

/* Stato vuoto */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  padding: 40px;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-raised);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  border: 1px solid var(--border);
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
  text-align: center;
  max-width: 280px;
  line-height: 1.6;
}

/* Header chat */
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  min-height: 60px;
  flex-shrink: 0;
}

.chat-header-info { flex: 1; min-width: 0; }

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-call-action {
  padding: 7px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-call-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-call-action.video:hover { color: var(--accent); border-color: var(--accent); }
.btn-call-action.audio:hover { color: var(--green); border-color: var(--green); }
.btn-call-action.remote:hover { color: var(--yellow); border-color: var(--yellow); }

/* ==================== MESSAGGI ==================== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 8px;
}

.message-group.own { align-items: flex-end; }

.message-sender-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 0 4px;
}

.message-group.own .message-sender-info {
  flex-direction: row-reverse;
}

.msg-avatar img, .msg-avatar .avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  font-size: 11px;
}

.sender-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.message-bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 18px;
  position: relative;
  word-break: break-word;
  line-height: 1.5;
  font-size: 14px;
}

.message-group.other .message-bubble {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.message-group.own .message-bubble {
  background: var(--accent);
  color: white;
  border-top-right-radius: 4px;
}

.message-time {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  text-align: right;
  margin-top: 4px;
  display: block;
}

.message-group.other .message-time {
  color: var(--text-muted);
}

.message-bubble:hover .message-actions {
  opacity: 1;
}

.message-actions {
  position: absolute;
  top: -32px;
  right: 0;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: var(--transition);
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
}

.message-bubble:hover .message-actions {
  opacity: 1;
  pointer-events: all;
}

.message-group.own .message-actions { right: auto; left: 0; }

.action-btn {
  padding: 4px 8px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Media nell'chat */
.message-image {
  max-width: 280px;
  max-height: 280px;
  border-radius: 12px;
  cursor: pointer;
  object-fit: cover;
  display: block;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}

.message-file-icon { font-size: 24px; }

.message-file-info { flex: 1; min-width: 0; }

.message-file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-file-size { font-size: 11px; opacity: 0.6; }

/* Reazioni */
.message-reactions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.reaction-pill {
  padding: 2px 8px;
  background: var(--bg-active);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.reaction-pill:hover { border-color: var(--accent); }

/* Indicatore digitazione */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 28px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ==================== INPUT MESSAGGIO ==================== */
.chat-input-wrapper {
  padding: 12px 20px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-raised);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.reply-preview-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  transition: var(--transition);
}

.chat-input-bar:focus-within {
  border-color: var(--border-active);
}

.chat-input-tools {
  display: flex;
  gap: 2px;
  padding-bottom: 2px;
}

.chat-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.5;
  padding: 3px 0;
}

.chat-textarea::placeholder { color: var(--text-muted); }

.btn-send {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: var(--shadow-accent);
}

.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ==================== AREA VIDEOCHIAMATA ==================== */
#call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 500;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.call-header-bar {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10,10,12,0.8);
  border-bottom: 1px solid var(--border);
}

.call-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.call-duration {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--green);
}

.call-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.videos-grid {
  flex: 1;
  padding: 20px;
  display: grid;
  gap: 12px;
  overflow: hidden;
  align-content: center;
  justify-content: center;
}

.videos-grid.participants-1 {
  grid-template-columns: 1fr;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.videos-grid.participants-2 { grid-template-columns: 1fr 1fr; }
.videos-grid.participants-3,
.videos-grid.participants-4 { grid-template-columns: 1fr 1fr; }
.videos-grid.participants-5,
.videos-grid.participants-6 { grid-template-columns: 1fr 1fr 1fr; }
.videos-grid.participants-many { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.video-tile {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16/9;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-tile-name {
  font-size: 13px;
  font-weight: 500;
  color: white;
}

.video-tile-badges {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.media-badge {
  padding: 2px 6px;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  font-size: 11px;
  color: white;
}

.media-badge.muted { color: var(--red); }

.video-tile.speaking {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green);
}

.video-tile.screen-share {
  border-color: var(--accent);
  grid-column: 1 / -1;
}

/* Pannello laterale chiamata */
.call-sidebar {
  width: 320px;
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.call-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.call-sidebar-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.call-sidebar-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.call-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.call-chat-msg {
  display: flex;
  gap: 8px;
}

.call-chat-bubble {
  flex: 1;
  background: var(--bg-raised);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.call-chat-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.call-participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.call-participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.call-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.call-input-area input {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}

.call-input-area input:focus { border-color: var(--accent); }

/* Controls chiamata */
.call-controls {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(10,10,12,0.8);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.ctrl-btn:hover { background: var(--bg-hover); transform: scale(1.08); }
.ctrl-btn.active { background: var(--accent-dim); border-color: var(--accent); }
.ctrl-btn.danger { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.ctrl-btn.danger:hover { background: var(--red); color: white; }
.ctrl-btn.off { background: var(--bg-active); color: var(--text-muted); }

/* ==================== INCOMING CALL ==================== */
.incoming-call-overlay {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  z-index: 900;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 300px;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.incoming-call-pulse {
  animation: pulseRing 2s infinite;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(124, 124, 255, 0.4); }
  70% { box-shadow: 0 0 0 20px rgba(124, 124, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 124, 255, 0); }
}

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

.btn-secondary {
  padding: 9px 18px;
  background: var(--bg-active);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  padding: 9px 18px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover { background: var(--red); color: white; }

/* ==================== REMOTE CONTROL ==================== */
.remote-control-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 600;
  display: flex;
  flex-direction: column;
}

.remote-header {
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.remote-badge {
  padding: 4px 10px;
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 600;
}

.remote-screen {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: none;
}

.remote-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ==================== NOTIFICHE TOAST ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--yellow); }

/* ==================== RICERCA GLOBALE ==================== */
.search-bar {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

.search-icon { font-size: 13px; color: var(--text-muted); }

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
}

.search-input::placeholder { color: var(--text-muted); }

/* ==================== STATUS SELECTOR ==================== */
.status-menu {
  position: absolute;
  bottom: 60px;
  left: 8px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 200px;
}

.status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  color: var(--text-secondary);
}

.status-option:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    z-index: 300;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    left: 0;
  }

  .chat-header {
    padding: 10px 14px;
  }

  .messages-container {
    padding: 12px;
  }

  .call-sidebar {
    display: none;
  }

  .call-sidebar.open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 600;
    width: 100%;
  }

  .videos-grid.participants-2,
  .videos-grid.participants-3,
  .videos-grid.participants-4 {
    grid-template-columns: 1fr;
  }

  .message-bubble { max-width: 85%; }

  .btn-call-action span { display: none; }

  .ctrl-btn { width: 46px; height: 46px; font-size: 18px; }

  .modal { padding: 20px; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .incoming-call-overlay { left: 12px; right: 12px; }
}

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.overflow-hidden { overflow: hidden; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.font-mono { font-family: var(--font-mono); }

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-void);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  flex-direction: column;
  gap: 16px;
}

.page-loader-logo {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  animation: pulse 2s infinite;
  box-shadow: 0 0 40px var(--accent-glow);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.divider-date {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  margin: 8px 0;
}

.divider-date::before, .divider-date::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider-date span {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Emoji picker trigger */
.emoji-btn { font-size: 18px; cursor: pointer; }

/* Drag & drop */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(124, 124, 255, 0.15);
  border: 3px dashed var(--accent);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent);
  font-weight: 600;
  pointer-events: none;
}
