/* ==========================================================================
   Chronote UI Components — Lock Screen, Timeline, Modals & Forms
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Lock Screen & Keypad
   -------------------------------------------------------------------------- */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 40px 24px calc(30px + var(--safe-bottom));
  overflow-y: auto;
}

.lock-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 20px;
}

.lock-logo-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
}

.lock-logo {
  width: 100%;
  height: 100%;
}

.lock-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.lock-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* PIN Dots Display */
.pin-dots-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 32px 0 20px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  background-color: transparent;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pin-dot.filled {
  border-color: var(--accent-blue);
  background-color: var(--accent-blue);
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.pin-dot.error {
  border-color: var(--accent-rose);
  background-color: var(--accent-rose);
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Numeric Keypad */
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.keypad-btn {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 1.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.keypad-btn:active {
  background-color: var(--accent-blue);
  color: #ffffff;
  transform: scale(0.92);
}

.keypad-btn.action-btn {
  background-color: transparent;
  border-color: transparent;
  font-size: 1rem;
  color: var(--text-secondary);
}

.keypad-btn.action-btn:active {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.keypad-btn svg {
  width: 26px;
  height: 26px;
}

.bio-btn {
  color: var(--accent-emerald) !important;
}

/* --------------------------------------------------------------------------
   2. Main View: Chronotes List
   -------------------------------------------------------------------------- */
.main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  padding-bottom: calc(75px + var(--safe-bottom));
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 8px;
}

.search-box svg {
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.90rem;
  width: 100%;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-card:active {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-blue);
  transform: scale(0.98);
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-card-date {
  font-size: 0.78rem;
  color: var(--accent-blue);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.note-card-badge {
  background-color: var(--bg-card);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.note-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.note-card-preview {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-sans);
  line-height: 1.35;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

/* --------------------------------------------------------------------------
   3. Detail View: Active Chronote & Timeline
   -------------------------------------------------------------------------- */
.detail-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(75px + var(--safe-bottom));
}

.detail-header-card {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subject-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.subject-input:focus {
  border-color: var(--border-focus);
}

.meta-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-field {
  display: flex;
  align-items: center;
  gap: 5px;
  background-color: var(--bg-card);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.80rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 110px;
}

.meta-field span,
.time-input-group span,
.field-tag {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: -0.01em;
  user-select: none;
}

.meta-field input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.80rem;
  width: 100%;
  min-width: 0;
}

.quick-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

/* Timeline Stream */
.timeline-stream {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.timeline-stream::before {
  content: '';
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 21px;
  width: 2px;
  background-color: var(--border-subtle);
  z-index: 1;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.timeline-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: 2px solid var(--accent-blue);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--bg-primary);
}

.timeline-dot svg {
  width: 11px;
  height: 11px;
}

.timeline-item.is-range .timeline-dot {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.timeline-content-card {
  flex: 1;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.timeline-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.time-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-blue);
}

.timeline-item.is-range .time-pill {
  color: var(--accent-emerald);
}

.time-duration-badge {
  font-size: 0.70rem;
  color: var(--text-muted);
  font-weight: 500;
}

.time-pill.diff-date {
  border-color: rgba(245, 158, 11, 0.5);
}

.pill-date-tag {
  color: var(--accent-amber);
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 2px;
}

.timeline-item-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.item-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
}

.item-action-btn:active {
  color: var(--text-primary);
}

.item-action-btn.btn-delete:active {
  color: var(--accent-rose);
}

.timeline-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.38;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --------------------------------------------------------------------------
   4. Entry Editor Drawer / Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background-color: var(--bg-secondary);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background-color: var(--border-subtle);
  align-self: center;
  margin-bottom: 2px;
}

.sheet-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entry-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  flex: 1;
}

.time-input-group input[type="time"],
.time-input-group input[type="date"] {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-mono);
  width: 100%;
}

.toggle-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-switch-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-emerald);
}

.textarea-container {
  position: relative;
  width: 100%;
}

.entry-textarea {
  width: 100%;
  min-height: 80px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  padding-right: 42px; /* space for mic button */
  color: var(--text-primary);
  font-size: 0.90rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  line-height: 1.4;
}

.entry-textarea:focus {
  border-color: var(--border-focus);
}

.voice-mic-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.voice-mic-btn.listening {
  color: var(--accent-rose);
  background-color: rgba(244, 63, 94, 0.15);
  animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); }
  100% { transform: scale(1); }
}

/* Settings Form */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.settings-item-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-item-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.settings-item-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   5. Snippets & Textes Rapides
   -------------------------------------------------------------------------- */
.snippets-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 2px 0 6px;
}

.snippets-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.snippets-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.snippets-scroll::-webkit-scrollbar {
  display: none;
}

.snippet-chip {
  flex-shrink: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.snippet-chip:active {
  background-color: var(--accent-blue);
  color: #ffffff;
  transform: scale(0.95);
}

/* --------------------------------------------------------------------------
   6. Suivi de Tâche en direct (Mode Chrono)
   -------------------------------------------------------------------------- */
.task-timer-toolbar {
  margin-top: 4px;
}

.active-task-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(16, 185, 129, 0.15));
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 8px 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.active-task-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.active-task-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseEmerald 1.5s infinite;
  flex-shrink: 0;
}

@keyframes pulseEmerald {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.active-task-details {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.active-task-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-task-meta {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.active-task-meta strong {
  color: var(--accent-emerald);
  font-family: var(--font-mono);
}

.active-task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.80rem;
  min-height: 30px;
}

/* --------------------------------------------------------------------------
   7. Toast avec Annulation (Undo)
   -------------------------------------------------------------------------- */
.toast.toast-undo {
  border-left: 4px solid var(--accent-amber);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toast-action-btn {
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.toast-action-btn:active {
  background: var(--accent-blue-hover);
  transform: scale(0.95);
}


/* --------------------------------------------------------------------------
   8. Mot de passe (écran de verrouillage)
   -------------------------------------------------------------------------- */
.passphrase-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin: 28px auto 0;
}

.passphrase-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1.05rem;
  color: var(--text-primary);
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
}

.passphrase-input:focus {
  border-color: var(--border-focus);
}

.passphrase-input.error {
  border-color: var(--accent-rose);
  animation: shake 0.4s ease-in-out;
}

.passphrase-actions {
  display: flex;
  gap: 8px;
}

.lock-secondary-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.lock-link-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

/* --------------------------------------------------------------------------
   9. Tâche en cours dans la liste des chroniques
   -------------------------------------------------------------------------- */
.note-card-task {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-emerald);
  min-width: 0;
}

.note-card-task-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   10. Éditeur de textes rapides / intitulés (paramètres)
   -------------------------------------------------------------------------- */
.chips-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips-editor-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.editable-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px 4px 2px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.editable-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editable-chip-remove {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.editable-chip-remove:active {
  background-color: var(--accent-rose);
  color: #ffffff;
}

.chips-editor-add {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chips-editor-add .subject-input {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}
