/* ============================================================
   VARIABLES DE THEME
   ============================================================ */

:root {
  /* Couleurs */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-terminal: #0f0f1a;
  --text-primary: #e0e0e0;
  --text-secondary: #8888aa;
  --accent: #4fc3f7;
  --accent-hover: #81d4fa;
  --success: #66bb6a;
  --warning: #ffa726;
  --error: #ef5350;
  --border: #2a2a4a;

  /* Polices */
  --font-mono: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;

  /* Safe area (notch iOS) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================================
   RESET ET BASE
   ============================================================ */

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

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

/* ============================================================
   LAYOUT GENERAL
   ============================================================ */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.screen.hidden {
  display: none;
}

/* ============================================================
   ECRAN LOGIN
   ============================================================ */

#screen-login {
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.logo {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 40px;
  color: var(--accent);
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#login-form input {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.error {
  margin-top: 12px;
  padding: 12px;
  font-size: 14px;
  color: var(--error);
  background: rgba(239, 83, 80, 0.1);
  border-radius: 8px;
}

.error.hidden {
  display: none;
}

/* ============================================================
   ECRAN SESSIONS
   ============================================================ */

.sessions-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sessions-header h2 {
  font-size: 24px;
  font-weight: 600;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.session-card {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-secondary);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.session-card:hover {
  background: rgba(79, 195, 247, 0.1);
}

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

.session-card-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-card-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.status-dot.idle {
  background: var(--success);
}

.status-dot.active {
  background: var(--warning);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.unknown {
  background: var(--text-secondary);
}

/* ============================================================
   ECRAN SESSION (PRINCIPAL)
   ============================================================ */

#screen-session {
  display: flex;
  flex-direction: column;
}

/* Onglets */
.tabs-bar {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-add, .tab-settings {
  flex-shrink: 0;
  margin-left: auto;
  width: 36px;
  height: 36px;
  font-size: 20px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab-add:hover, .tab-settings:hover {
  background: rgba(79, 195, 247, 0.1);
  color: var(--accent);
}

.tab-settings {
  margin-left: 4px;
}

/* Menu settings */
.settings-menu {
  position: absolute;
  top: 52px;
  right: 12px;
  width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  z-index: 1000;
}

.settings-menu.hidden {
  display: none;
}

.settings-menu-item {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s;
}

.settings-menu-item:last-child {
  border-bottom: none;
}

.settings-menu-item:hover {
  background: rgba(79, 195, 247, 0.1);
}

.settings-menu-item:active {
  background: rgba(79, 195, 247, 0.2);
}

/* Status bar */
.status-bar {
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
  background: rgba(255, 167, 38, 0.1);
  color: var(--warning);
  border-bottom: 1px solid var(--border);
}

.status-bar.hidden {
  display: none;
}

/* Vue terminal */
.terminal-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  background: var(--bg-terminal);
  -webkit-overflow-scrolling: touch;
}

#terminal-content {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Zone de controle */
.control-zone {
  flex-shrink: 0;
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.control-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#text-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px;
  font-size: 16px;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

#text-input:focus {
  border-color: var(--accent);
}

.btn-mic, .btn-send {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-mic:hover, .btn-send:hover {
  background: var(--accent-hover);
}

.btn-mic:active, .btn-send:active {
  transform: scale(0.95);
}

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

.btn-mic svg, .btn-send svg {
  width: 24px;
  height: 24px;
}

/* Bouton micro en enregistrement */
.btn-mic.recording {
  background: var(--error);
  animation: pulse 1.5s ease-in-out infinite;
}

.mic-timer {
  position: absolute;
  bottom: -20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mic-timer.hidden {
  display: none;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

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

/* ============================================================
   UTILITAIRES
   ============================================================ */

.hidden {
  display: none !important;
}
