/* ==================== STYLES GÉNÉRAUX & VARIABLES ==================== */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --msg-sent: #1d4ed8;
  --msg-received: #334155;
  --danger: #ef4444;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ==================== AUTHENTIFICATION ==================== */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.auth-card {
  background-color: var(--bg-secondary);
  padding: 2.5rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 3rem;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.input-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.input-group input {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--accent-color);
}

.btn {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
}

/* ==================== INTERFACE DE CHAT ==================== */
.app-wrapper {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Barre latérale */
.sidebar {
  width: 320px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-color);
}

.username {
  font-weight: 600;
  font-size: 0.95rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: color 0.2s, background-color 0.2s;
}

.icon-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-tertiary);
}

.search-box {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  background-color: var(--bg-primary);
  margin: 0.75rem;
  border-radius: 8px;
  gap: 0.5rem;
}

.search-box i {
  color: var(--text-muted);
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-main);
  outline: none;
  width: 100%;
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  gap: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background-color 0.2s;
}

.contact-item:hover, .contact-item.active {
  background-color: var(--bg-tertiary);
}

.contact-info {
  display: flex;
  flex-direction: column;
}

.contact-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.contact-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Zone Principale de Chat */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
}

.no-chat-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  color: var(--bg-tertiary);
}

.active-chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.chat-contact-info h4 {
  font-size: 1rem;
  font-weight: 600;
}

.status-indicator {
  font-size: 0.75rem;
  color: #10b981;
}

/* Container de messages */
.messages-container {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.message {
  max-width: 65%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.message.sent {
  align-self: flex-end;
  background-color: var(--msg-sent);
  color: white;
  border-bottom-right-radius: 2px;
}

.message.received {
  align-self: flex-start;
  background-color: var(--msg-received);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.message-image {
  max-width: 100%;
  max-height: 250px;
  border-radius: 8px;
  margin-top: 0.25rem;
}

.message-audio {
  width: 220px;
  margin-top: 0.25rem;
}

.message-time {
  display: block;
  font-size: 0.68rem;
  opacity: 0.7;
  text-align: right;
  margin-top: 0.35rem;
}

/* Zone d'envoi */
.chat-input-area {
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.message-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.message-form input[type="text"] {
  flex: 1;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: 20px;
  color: var(--text-main);
  outline: none;
}

.btn-send {
  width: auto;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--accent-color);
  color: white;
}

.recording-active {
  color: var(--danger) !important;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Mobile responsive */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }

  .sidebar {
    width: 100%;
  }

  .app-wrapper.chat-active .sidebar {
    display: none;
  }

  .app-wrapper:not(.chat-active) .chat-area {
    display: none;
  }
}