:root {
  color-scheme: light;
  --primary: #202245;
  --primary-light: #343674;
  --accent: #ffb703;
  --danger: #d62828;
  --bg: #f4f4f8;
  --surface: #ffffff;
  --text: #1f2333;
  --text-muted: #5c6075;
  --border: #d5d7e3;
  
  --font-size: 14px;
  --font-size-small: 12px;
  --font-size-title: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.25;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: var(--font-size-title);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.user-menu {
  position: relative;
}

.user-button {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease;
}

.user-button:hover {
  background: var(--primary-light);
}

.indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: var(--font-size-small);
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-width: 180px;
  box-shadow: 0 12px 32px rgba(17, 20, 52, 0.15);
  display: grid;
  gap: 12px;
  z-index: 20;
}

.user-dropdown strong {
  font-size: var(--font-size);
}

.user-dropdown button {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--border);
  font-weight: 600;
}

.app-version {
  font-size: var(--font-size-small);
  color: var(--text-muted);
  text-align: center;
}

main {
  flex: 1;
  padding: clamp(16px, 6vw, 48px);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sessions-list {
  display: grid;
  gap: 16px;
  max-width: 650px;
  width: 100%;
  margin: 0 auto;
}

.session-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  display: grid;
  gap: 14px;
  box-shadow: 0 8px 20px rgba(13, 18, 47, 0.08);
}

.session-card header {
  display: flex;
  flex-wrap: wrap;
  row-gap: 6px;
  column-gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.session-meta {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--font-size);
}

.session-meta span {
  display: flex;
  gap: 6px;
  align-items: center;
}

.session-meta strong {
  color: var(--text);
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.session-actions button {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.session-actions button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.session-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.participants-line {
  color: var(--text-muted);
  font-size: var(--font-size);
}

.participants-line strong {
  color: var(--text);
}

/* Chat styles */
.chat-section {
  margin-top: 0;
  padding-top: 0;
}
.chat-toggle {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  font-size: var(--font-size);
  list-style: none;
}
.chat-toggle::-webkit-details-marker {
  display: none;
}
.chat-toggle::before {
  content: '▶ ';
  font-size: var(--font-size-small);
  margin-right: 0.3rem;
}
details[open] .chat-toggle::before {
  content: '▼ ';
}
.chat-messages {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 8px;
  margin: 0.5rem 0;
}
.chat-messages:empty::before {
  content: 'Aucun message';
  color: var(--text-muted);
  font-style: italic;
  font-size: var(--font-size);
}
.chat-message {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.chat-message:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.chat-message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}
.chat-message-sender {
  font-weight: 600;
  color: var(--primary);
  font-size: var(--font-size);
}
.chat-message-time {
  font-size: var(--font-size-small);
  color: var(--text-muted);
}
.chat-message-text {
  font-size: var(--font-size);
  color: var(--text);
  word-break: break-word;
}
.chat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.chat-form input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--font-size);
}
.chat-form button {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--font-size);
  font-weight: 600;
}
.chat-form button:hover {
  opacity: 0.9;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #1a1a1a;
  font-size: 32px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(255, 183, 3, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 15;
}

.fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 36px rgba(255, 183, 3, 0.5);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 15, 37, 0.4);
  z-index: 30;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.modal-card {
  background: var(--surface);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 36px);
  width: min(420px, 100%);
  box-shadow: 0 24px 48px rgba(12, 15, 37, 0.25);
  display: grid;
  gap: 18px;
  border: 1px solid var(--border);
}

.modal-card h1,
.modal-card h2 {
  margin: 0;
  text-align: center;
}

.auth-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(12, 15, 37, 0.2);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.auth-tabs button {
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  transition: background 0.2s ease;
}

.auth-tabs button.active {
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(12, 15, 37, 0.18);
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: var(--font-size);
}

input,
select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: var(--font-size);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid var(--primary-light);
  border-color: transparent;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.form-actions button {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

/* Participants Modal */
.participants-modal-card {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.participants-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.participants-modal-header h2 {
  margin: 0;
  text-align: left;
}

.participants-list {
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.participants-empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  font-style: italic;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 6px;
}

.participant-item:last-child {
  margin-bottom: 0;
}

.participant-icon {
  width: 24px;
  text-align: center;
  font-size: var(--font-size);
}

.participant-name {
  flex: 1;
  font-weight: 500;
}

.participant-remove {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: var(--font-size-title);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.participant-remove:hover {
  opacity: 1;
}

.add-participant-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.add-participant-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--font-size);
}

.add-participant-form button {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: var(--font-size);
  cursor: pointer;
}

.toast-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 24px;
  display: grid;
  gap: 10px;
  z-index: 50;
  width: min(90%, 400px);
}

.toast {
  background: var(--surface);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(10, 12, 28, 0.18);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(-12px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: var(--font-size);
  color: var(--text-muted);
}

.session-title {
  font-size: var(--font-size-title);
  font-weight: 600;
}

.session-title span {
  color: var(--text-muted);
  font-size: var(--font-size);
  font-weight: 500;
}

.pill {
  display: inline-flex;
  align-items: center;
  background: rgba(32, 34, 69, 0.08);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--font-size);
}

@media (min-width: 720px) {
  .sessions-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 12px 16px;
  }
  .session-card {
    padding: 16px;
  }
  .fab {
    right: 16px;
    bottom: 16px;
  }
}

/* Install Prompt Styles */
.install-prompt {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
  background: rgba(12, 15, 37, 0.5);
  backdrop-filter: blur(4px);
}

.install-prompt-card {
  background: var(--surface);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 32px);
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(12, 15, 37, 0.3);
  border: 1px solid var(--border);
  display: grid;
  gap: 20px;
}

.install-prompt-header {
  display: grid;
  gap: 12px;
  text-align: center;
}

.install-prompt-header h2 {
  margin: 0;
  font-size: var(--font-size-title);
  color: var(--primary);
}

.install-prompt-header p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.install-instructions {
  background: var(--bg);
  border-radius: 12px;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.install-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.install-step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size);
}

.install-step-text {
  flex: 1;
  line-height: 1.6;
  padding-top: 2px;
}

.install-step-text strong {
  color: var(--primary);
}

.install-prompt-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.install-prompt-actions button {
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.install-prompt-actions button:active {
  transform: scale(0.98);
}

.btn-dismiss {
  background: var(--border);
  color: var(--text);
}

.btn-understood {
  background: var(--primary);
  color: #fff;
}
