/* ========== Page-level overrides (flush layout) ========== */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  padding: 0.4rem 1rem;
  flex-shrink: 0;
}

main.firechat-container {
  padding: 0;
  max-width: 100%;
  width: 100%;
  margin: 0;
  flex: 1;
  height: auto;
}

/* FireChat Styles - Minimal, Clean Design */

.firechat-container {
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ========== Users Sidebar ========== */
.users-sidebar {
  width: 220px;
  background: #2c2c2c;
  border-right: 1px solid #444;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.users-sidebar h2 {
  padding: 0.6rem 1rem;
  margin: 0;
  font-size: 1rem;
  color: #fff;
  border-bottom: 1px solid #444;
  background: #222;
  white-space: nowrap;
}

.connection-test {
  padding: 0.6rem 1rem;
  border-top: 1px solid #444;
  margin-top: auto;
}

.connection-test button {
  width: 100%;
  padding: 0.4rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

#online-users-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
}

#online-users-list li {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #444;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
}

.user-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.call-user-btn {
  background: #4caf50;
  border: none;
  border-radius: 4px;
  color: #fff;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.call-user-btn:hover:not(:disabled) {
  background: #45a049;
}

.call-user-btn:disabled {
  background: #555;
  cursor: default;
  color: #999;
}

#online-users-list li:hover {
  background: #333;
}

#online-users-list li.no-users {
  color: #888;
  cursor: default;
  text-align: center;
}

#online-users-list li.no-users:hover {
  background: transparent;
}

.user-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  display: inline-block;
  flex-shrink: 0;
}

.user-status.in_call {
  background: #ff9800;
}

.user-status.busy {
  background: #f44336;
}

/* ========== Video Area ========== */
.video-area {
  flex: 1;
  position: relative;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* ========== State Screens ========== */
.state-screen {
  text-align: center;
  padding: 1rem;
  max-width: 500px;
  width: 100%;
  overflow-y: auto;
  max-height: 100%;
}

.state-screen h2 {
  margin-bottom: 0.75rem;
  font-size: 1.3rem;
}

.state-screen p {
  font-size: 1rem;
  color: #ccc;
  margin-bottom: 0.75rem;
}

.caller-name {
  font-size: 1.3rem !important;
  font-weight: bold;
  color: #4caf50 !important;
}

/* Spinner for connecting state */
.spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid #4caf50;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

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

/* ========== Active Call State ========== */
#active-call-state {
  width: 100%;
  height: 100%;
  position: relative;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

#local-video {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 160px;
  height: 120px;
  border-radius: 8px;
  border: 2px solid #fff;
  object-fit: cover;
  background: #000;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

/* ========== Call Controls ========== */
.call-controls {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  backdrop-filter: blur(10px);
}

.control-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.control-btn.active {
  background: #4caf50;
}

.control-btn.muted {
  background: #f44336;
}

.control-btn.danger {
  background: #f44336;
}

.control-btn.danger:hover {
  background: #d32f2f;
}

.control-btn .icon {
  font-size: 1.3rem;
}

/* ========== Chat Panel ========== */
.chat-panel {
  position: absolute;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100%;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(10px);
  border-left: 1px solid #444;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
  z-index: 10;
}

.chat-panel.open {
  right: 0;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #444;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h3 {
  margin: 0;
  font-size: 1rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #ccc;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-message {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  max-width: 80%;
  word-wrap: break-word;
  font-size: 0.9rem;
}

.chat-message.sent {
  background: #4caf50;
  align-self: flex-end;
  margin-left: auto;
}

.chat-message.received {
  background: #555;
  align-self: flex-start;
}

.chat-message .timestamp {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.2rem;
}

.chat-input {
  display: flex;
  padding: 0.75rem;
  border-top: 1px solid #444;
  gap: 0.5rem;
}

.chat-input input {
  flex: 1;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 0.9rem;
}

.chat-input input:focus {
  outline: none;
  border-color: #4caf50;
}

.chat-input button {
  padding: 0.6rem 1rem;
  background: #4caf50;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.chat-input button:hover {
  background: #45a049;
}

/* ========== Toasts ========== */
.toast {
  position: fixed;
  top: 70px;
  right: 16px;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  background: #333;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  font-size: 0.9rem;
  animation: slideIn 0.3s ease;
}

.toast.error {
  background: #f44336;
}

.toast.success {
  background: #4caf50;
}

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

/* ========== Buttons ========== */
button.success {
  background: #4caf50;
  border: none;
  color: white;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

button.success:hover {
  background: #45a049;
}

button.danger {
  background: #f44336;
  border: none;
  color: white;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

button.danger:hover {
  background: #d32f2f;
}

.button-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* ========== Test Result ========== */
#test-result-content {
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 8px;
  margin: 0.75rem 0;
  overflow-y: auto;
}

#test-result-content h3 {
  margin-top: 0.75rem;
  margin-bottom: 0.4rem;
  color: #4caf50;
  font-size: 0.95rem;
}

#test-result-content ul {
  list-style: none;
  padding-left: 0.75rem;
}

#test-result-content li {
  margin: 0.4rem 0;
  padding-left: 1.25rem;
  position: relative;
  font-size: 0.85rem;
}

#test-result-content li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #4caf50;
  font-weight: bold;
}

#test-result-content li.fail::before {
  content: "✗";
  color: #f44336;
}

/* ========== Mobile ========== */
@media (max-width: 768px) {
  #local-video {
    width: 100px;
    height: 75px;
    top: 8px;
    right: 8px;
  }

  .chat-panel {
    width: 100%;
    right: -100%;
  }

  .chat-panel.open {
    right: 0;
  }

  .call-controls {
    padding: 0.6rem 1rem;
    gap: 0.5rem;
  }

  .control-btn {
    width: 46px;
    height: 46px;
  }

  .control-btn .icon {
    font-size: 1.1rem;
  }

  .state-screen {
    padding: 0.75rem;
  }
}
