/* BouchardNDL App - Design mobile-first */
:root {
  --primary: #ffffff;
  --primary-dark: #e5e5e5;
  --bg-dark: #ffffff;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #22c55e;
}

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

html, body {
  overflow: hidden;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Transparent : le fond métallique / dégradé vient de base.css (body::before). */
  background: transparent;
  min-height: 100vh;
  color: var(--text);
  margin: 0;
}

/* Mode APP (défaut) - plein écran comme une vraie app */
#simulator-wrapper.app-mode {
  width: 100%;
  min-height: 100vh;
  padding: 0;
}

#phone-frame.app-mode {
  background: transparent;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

#app-container {
  background: transparent;
  min-height: 100vh;
  height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Écrans */
.screen {
  display: none;
  flex-direction: column;
  padding: 24px;
  padding-bottom: 24px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.screen.active {
  display: flex;
}

.screen-header {
  text-align: center;
  margin-bottom: 32px;
}

.screen-header .logo {
  width: 80px;
  height: auto;
  margin-bottom: 16px;
}

.screen-header h1, .screen-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.screen-header .subtitle,
.screen-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Formulaire */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.input-group input {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
}

.input-group input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Champs tactiles (min 44px) pour smartphone */
.input-group input {
  min-height: 48px;
  font-size: 16px; /* évite le zoom sur iOS */
}

/* Mot de passe avec œil afficher/masquer */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrap input {
  padding-right: 48px;
  flex: 1;
}
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
}
.password-toggle:hover,
.password-toggle:focus {
  color: var(--text);
  outline: none;
}
.password-toggle .icon-eye,
.password-toggle .icon-eye-off {
  pointer-events: none;
}
.password-wrap.show-password .icon-eye {
  display: none;
}
.password-wrap.show-password .icon-eye-off {
  display: block !important;
}

/* Message d'erreur */
.error-msg {
  display: none;
  background: rgba(220, 38, 38, 0.15);
  color: #f87171;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.version {
  margin-top: 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-primary, .btn-secondary {
  padding: 16px 24px;
  min-height: 48px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

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

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

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

.btn-block {
  width: 100%;
  text-align: center;
  text-decoration: none;
  display: block;
}

.hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card);
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  text-align: center;
  margin-top: 8px;
}

.mode-toggle {
  margin-top: 24px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 12px;
}

.mode-toggle label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Login - en-tête */
.login-header {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.login-logo {
  max-width: 140px;
  height: auto;
}
.login-title {
  font-size: clamp(1.85rem, 4.5vmin + 0.5rem, 2.35rem);
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

/* Dashboard - design moderne */
#dashboard-screen.screen {
  padding: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

#dashboard-screen .dashboard-header {
  margin: 0;
  padding: 16px 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dashboard-logo-wrap {
  background: #fff;
  width: 100%;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dashboard-logo {
  max-width: 120px;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.dashboard-header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
  padding: 12px 24px 16px;
}
.dashboard-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 20px;
  -webkit-overflow-scrolling: touch;
}
.dashboard-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px 0;
}
.dashboard-card-dashboard,
.dashboard-card-publication {
  min-height: 175px;
}
.dashboard-card-photos {
  min-height: 175px;
}
.dashboard-card-contact {
  min-height: 175px;
}
.dashboard-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 0;
  min-width: 0;
}
.dashboard-card-feuelle {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.08) 100%);
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.15);
}
.dashboard-card-feuelle:hover,
.dashboard-card-feuelle:active {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.28) 0%, rgba(37, 99, 235, 0.15) 100%);
  border-color: var(--primary);
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
}
.dashboard-card-empty {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
  cursor: default;
  pointer-events: none;
}
.dashboard-card-icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}
.dashboard-card-feuelle .dashboard-card-icon {
  background: rgba(255, 255, 255, 0.15);
}
.dashboard-card-label {
  text-align: center;
  font-weight: 600;
}
/* Zone du bas : nav + footer */
.dashboard-bottom {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.dashboard-nav-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  margin: 0 12px 8px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dashboard-nav-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dashboard-nav-item:hover, .dashboard-nav-item:active {
  color: var(--text);
  background: rgba(0,0,0,0.05);
}
.dashboard-nav-item-logout,
.dashboard-nav-item-logout .dashboard-nav-icon,
.dashboard-nav-item-logout .dashboard-nav-icon svg,
.dashboard-nav-item-logout .dashboard-nav-label {
  color: #dc2626 !important;
  stroke: currentColor;
}
.dashboard-nav-item-logout:hover, .dashboard-nav-item-logout:active {
  color: #991b1b !important;
  background: rgba(220, 38, 38, 0.1);
}
.dashboard-nav-item-logout:hover .dashboard-nav-icon,
.dashboard-nav-item-logout:hover .dashboard-nav-icon svg,
.dashboard-nav-item-logout:hover .dashboard-nav-label,
.dashboard-nav-item-logout:active .dashboard-nav-icon,
.dashboard-nav-item-logout:active .dashboard-nav-icon svg,
.dashboard-nav-item-logout:active .dashboard-nav-label {
  color: #991b1b !important;
}
.dashboard-nav-icon { font-size: 1.2rem; }
.dashboard-nav-label { white-space: nowrap; }
.dashboard-footer {
  padding: 8px 24px 12px;
  flex-shrink: 0;
}
.dashboard-footer-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.dashboard-footer-row .btn-secondary {
  flex: 1;
}
/* Bouton chat IA - à droite, un peu au-dessus */
.chat-widget-btn {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.9) 0%, var(--primary) 100%);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: -8px;
}
.chat-widget-btn:hover,
.chat-widget-btn:active {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
.chat-widget-icon {
  font-size: 2rem;
}
/* Chatroom - style Messenger */
.chatroom.screen.active {
  padding: 0;
  display: flex !important;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chatroom-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}
.chatroom-back {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.chatroom-title {
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
}

.chatroom-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chatroom-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  cursor: pointer;
}

/* Bulles style Messenger */
.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: #0084ff;
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  margin-left: auto;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
}

.chatroom-footer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
}
.chatroom-footer input {
  flex: 1;
  padding: 12px 18px;
  border-radius: 24px;
  border: none;
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  min-height: 44px;
}
.chatroom-footer input::placeholder {
  color: var(--text-muted);
}
.chatroom-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #0084ff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chatroom-send:hover {
  background: #0066cc;
}
.chatroom-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.dashboard-copyright {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.dashboard-copyright-version {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.dashboard-login-version-value {
  color: var(--text);
  font-weight: 600;
}

/* WebView */
.webview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
}

.webview-title {
  font-size: 0.9rem;
  color: var(--text-muted);
}

#site-frame {
  flex: 1;
  border: none;
  background: white;
  min-height: 400px;
}

.app-mode #site-frame {
  border-radius: 0;
  min-height: 50vh;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Safe area pour encoche iPhone / barre de statut (--app-safe-* dans base.css ; plancher iOS) */
@supports (padding: env(safe-area-inset-top)) {
  #app-container {
    padding-top: var(--app-safe-top, env(safe-area-inset-top, 0px));
    padding-left: var(--app-safe-left, env(safe-area-inset-left, 0px));
    padding-right: var(--app-safe-right, env(safe-area-inset-right, 0px));
    padding-bottom: var(--app-safe-bottom, env(safe-area-inset-bottom, 0px));
  }
  /*
   * Écrans avec header qui gère déjà l’encoche (fixed top:0 + padding, ou header en flux) :
   * sinon padding-top du container = bande beige au-dessus du header blanc (Publication, etc.).
   * Dashboard / login / verify gardent le padding du container.
   */
  #app-container:has(#publication-screen.active),
  #app-container:has(#photos-screen.active),
  #app-container:has(#chat-screen.active),
  #app-container:has(#feuille-temps-screen.active),
  #app-container:has(#feuille-temps-projet-screen.active),
  #app-container:has(#feuille-temps-choisir-projet-screen.active),
  #app-container:has(#feuille-temps-jours-screen.active),
  #app-container:has(#feuille-temps-horaire-screen.active),
  #app-container:has(#feuille-temps-entree-screen.active),
  #app-container:has(#formulaire-screen.active),
  #app-container:has(#note-screen.active),
  #app-container:has(#note-edit-screen.active),
  #app-container:has(#note-view-screen.active),
  #app-container:has(#annonces-screen.active),
  #app-container:has(#projet-screen.active),
  #app-container:has(#gestion-compte-screen.active),
  #app-container:has(#gestion-compte-detail-screen.active),
  #app-container:has(#gestion-compte-create-screen.active),
  #app-container:has(#contact-screen.active),
  #app-container:has(#contact-detail-screen.active),
  #app-container:has(#notifications-center-screen.active),
  #app-container:has(#notifications-prefs-screen.active),
  #app-container:has(#conformite-lecture-screen.active),
  #app-container:has(#webview-screen.active) {
    padding-top: 0 !important;
  }
}

/* Login : espacement mobile */
#login-screen .form,
#verify-screen .form {
  gap: 20px;
  margin-top: 8px;
}

#login-screen .input-group,
#verify-screen .input-group {
  margin-bottom: 4px;
}
