:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #10b981;
  --accent: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --bg-light: #f8fafc;
  --bg-dark: #1e293b;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  --transition: all 0.25s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-light);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- LOGIN ---------- */
.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: #fff;
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: slideUp .4s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-title { font-size: 1.4rem; margin-bottom: 24px; color: var(--text-primary); font-weight: 700; }

.field {
  display: flex;
  align-items: center;
  background: var(--bg-light);
  border: 2px solid transparent;
  border-radius: var(--radius);
  margin-bottom: 14px;
  padding: 0 14px;
  transition: var(--transition);
}
.field:focus-within {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.field-icon { font-size: 1.1rem; margin-right: 10px; color: var(--text-muted); }
.field input {
  background: none;
  border: none;
  outline: none;
  width: 100%;
  padding: 12px 0;
  font-size: .95rem;
  font-family: var(--font);
}

.msg-error { color: var(--danger); font-size: .85rem; margin-top: 8px; font-weight: 500; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-dark); color: #fff; }
.btn-secondary:hover { background: #334155; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-light); color: var(--text-primary); }
.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; }
.btn-large {
  padding: 16px 32px;
  font-size: 16px;
  width: 100%;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.btn-close:hover { opacity: 0.7; }

.btn-dashed {
  background: transparent;
  border: 2px dashed var(--primary);
  color: var(--primary);
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  font-family: var(--font);
  font-size: .9rem;
}
.btn-dashed:hover {
  background: rgba(37,99,235,0.05);
  border-style: solid;
}

/* ---------- APP CONTAINER ---------- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- HEADER ---------- */
.capture-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  z-index: 10;
}
.capture-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}
.header-actions {
  display: flex;
  gap: 10px;
}

/* ---------- CAPTURE FORM ---------- */
.capture-form-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.form-group {
  margin-bottom: 24px;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 14px;
}
.form-group small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}
.label-optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.input-large,
.textarea-large {
  width: 100%;
  padding: 16px 14px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  font-family: var(--font);
  transition: var(--transition);
  background: #fff;
}
.input-large:focus,
.textarea-large:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea {
  resize: vertical;
  min-height: 100px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  transition: var(--transition);
  background: var(--bg-light);
}
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
  background: #fff;
}

.form-group.large .textarea-large {
  min-height: 200px;
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- CATEGORIES GRID ---------- */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  background: white;
  font-size: .85rem;
  font-weight: 500;
  user-select: none;
}
.checkbox-item:hover {
  border-color: var(--primary);
  background: rgba(37,99,235,0.05);
}
.checkbox-item input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.checkbox-item.checked {
  border-color: var(--primary);
  background: rgba(37,99,235,0.08);
  color: var(--primary);
  font-weight: 600;
}

/* ---------- FORM ACTIONS ---------- */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  animation: toastIn .3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- MODALS ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal.hidden {
  display: none !important;
}
.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-large {
  max-width: 680px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-body input[type="text"],
.modal-body input[type="url"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: var(--font);
  transition: var(--transition);
}
.modal-body input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.modal-actions {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ---------- FILE UPLOAD ---------- */
.file-upload-area {
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(37,99,235,0.02);
}
.file-upload-area:hover {
  background: rgba(37,99,235,0.05);
  border-color: #1d4ed8;
}
.file-upload-area.dragover {
  background: rgba(37,99,235,0.1);
  border-color: #1d4ed8;
}
.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
}
.upload-prompt span {
  font-weight: 600;
  color: var(--text-primary);
}
.upload-prompt small {
  color: var(--text-muted);
  font-size: 12px;
}
.files-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-light);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.file-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.file-icon { font-size: 18px; }
.file-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.file-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}
.file-size {
  font-size: 12px;
  color: var(--text-muted);
}
.file-actions {
  display: flex;
  gap: 8px;
}
.btn-download, .btn-remove-file {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.2s;
}
.btn-download { color: var(--primary); }
.btn-download:hover { background: rgba(37,99,235,0.1); }
.btn-remove-file { color: var(--danger); }
.btn-remove-file:hover { background: rgba(239,68,68,0.1); }
.attachments-list { margin-bottom: 16px; }
.attachments-list .file-item { background: white; }

/* ---------- IDEAS VIEW (fullscreen) ---------- */
.ideas-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  z-index: 500;
  display: flex;
  flex-direction: column;
}
.ideas-view.hidden {
  display: none !important;
}

.ideas-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
  box-shadow: var(--shadow);
  z-index: 10;
}
.ideas-header h2 {
  margin: 0;
  flex: 1;
  font-size: 20px;
}

.ideas-view-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ---------- FILTERS BAR ---------- */
.filters-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.filter-select,
.filter-search {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: var(--font);
  background: var(--bg-light);
  transition: var(--transition);
  color: var(--text-primary);
}
.filter-select:focus,
.filter-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ---------- IDEAS LIST ---------- */
.ideas-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.ideas-list:empty::after {
  content: '📭 Aucune idée trouvée';
  display: block;
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

.idea-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.idea-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.idea-card-title {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  font-size: .95rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idea-card-preview {
  color: var(--text-muted);
  font-size: .82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.idea-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.idea-tag {
  background: rgba(37,99,235,0.1);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
}
.idea-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

/* ---------- BADGES ---------- */
.idea-status {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
  display: inline-block;
}
.status-inbox { background: #e0e7ff; color: var(--primary); }
.status-categorisee { background: #d1fae5; color: var(--secondary); }
.status-en_cours { background: #fef3c7; color: #d97706; }
.status-appliquee { background: #d1fae5; color: #065f46; }
.status-rejetee { background: #fee2e2; color: var(--danger); }

/* ---------- RADIO PILLS ---------- */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.radio-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .82rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--bg-light);
  font-weight: 500;
  user-select: none;
}
.radio-pill:hover { border-color: var(--primary); }
.radio-pill.active { border-color: var(--primary); }
.radio-pill[data-value="inbox"].active { background: #e0e7ff; color: var(--primary); border-color: var(--primary); }
.radio-pill[data-value="categorisee"].active { background: #d1fae5; color: var(--secondary); border-color: var(--secondary); }
.radio-pill[data-value="en_cours"].active { background: #fef3c7; color: #d97706; border-color: #f59e0b; }
.radio-pill[data-value="appliquee"].active { background: #d1fae5; color: var(--secondary); border-color: var(--secondary); }
.radio-pill[data-value="rejetee"].active { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

/* ---------- INFO BLOCK ---------- */
.info-block {
  background: var(--bg-light);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.info-line {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  padding: 2px 0;
}
.info-label { color: var(--text-muted); font-weight: 500; }

/* ---------- HISTORIQUE ---------- */
.timeline { padding-left: 8px; }
.timeline-item {
  position: relative;
  padding: 6px 0 6px 20px;
  font-size: .82rem;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  margin-left: 4px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.timeline-item:last-child { border-left: 2px solid transparent; }
.timeline-date { font-weight: 500; color: var(--text-primary); }
.timeline-action { margin-left: 4px; }

/* ---------- CONFIRM OVERLAY ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.confirm-box {
  background: #fff;
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: slideUp .25s ease;
}
.confirm-box p { margin-bottom: 20px; font-size: .95rem; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .capture-form-container {
    padding: 20px;
    max-width: 100%;
  }
  .capture-header h1 { font-size: 18px; }
  .filters-bar {
    grid-template-columns: 1fr 1fr;
  }
  .ideas-list {
    grid-template-columns: 1fr;
  }
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .modal-content {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh;
    margin-top: auto;
  }
}

@media (max-width: 480px) {
  .capture-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  .capture-header h1 { font-size: 17px; }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .capture-form-container {
    padding: 16px;
  }
  .form-group.large .textarea-large {
    min-height: 150px;
  }
  .filters-bar {
    grid-template-columns: 1fr;
  }
  .categories-grid {
    grid-template-columns: 1fr;
  }
  .btn-large {
    padding: 14px 20px;
    font-size: 15px;
  }
  .ideas-header {
    padding: 12px 16px;
  }
  .ideas-view-content {
    padding: 12px;
  }
}
