/* Codeur Assistant — Styles principaux */
:root {
  --primary: #185FA5;
  --primary-hover: #134d88;
  --primary-light: #e8f0fa;
  --bg: #F1EFE8;
  --bg-white: #ffffff;
  --text: #1a1a1a;
  --text-light: #666666;
  --border: #d4d2cb;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffc107;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* Header */
.header {
  background: var(--primary);
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 28px;
  height: 28px;
  background: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 16px;
  font-weight: 600;
}

.header-subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Offer summary */
.offer-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.offer-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.offer-info-label {
  color: var(--text-light);
}

.offer-info-value {
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.offer-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.offer-description {
  font-size: 12px;
  color: var(--text-light);
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.4;
  padding: 8px;
  background: var(--bg);
  border-radius: 4px;
  margin-top: 8px;
}

/* Amount input */
.amount-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.amount-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.2s;
}

.amount-input:focus {
  outline: none;
  border-color: var(--primary);
}

.help-text {
  font-size: 11px;
  color: var(--text-light);
}

/* Tone selector */
.tone-selector {
  display: flex;
  gap: 8px;
}

.tone-btn {
  flex: 1;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.tone-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tone-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

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

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

.btn-primary:disabled {
  background: #a0b8d0;
  cursor: not-allowed;
}

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

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

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #218838;
}

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

.btn-danger:hover {
  background: #c82333;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.btn-group .btn {
  flex: 1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Textarea */
.response-textarea {
  width: 100%;
  min-height: 160px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  color: var(--text);
  transition: border-color 0.2s;
}

.response-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.response-textarea.over-limit {
  border-color: var(--danger);
}

/* Character counter */
.char-counter {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-light);
}

.char-counter.warning {
  color: var(--warning);
}

.char-counter.danger {
  color: var(--danger);
  font-weight: 600;
}

/* Status */
.status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin: 12px;
}

.status-info {
  background: var(--primary-light);
  color: var(--primary);
}

.status-error {
  background: #fde8ea;
  color: var(--danger);
}

.status-success {
  background: #e8f5e9;
  color: var(--success);
}

.status-warning {
  background: #fff8e1;
  color: #e65100;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-dark {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 13px;
}

/* History */
.history-list {
  list-style: none;
}

.history-item {
  padding: 12px;
  border-bottom: 1px solid var(--bg);
  cursor: pointer;
  transition: background 0.2s;
}

.history-item:hover {
  background: var(--bg);
}

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

.history-item-title {
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--primary);
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
}

.history-item-status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
}

.history-item-status.replied {
  background: #e8f5e9;
  color: var(--success);
}

.history-item-status.ignored {
  background: var(--bg);
  color: var(--text-light);
}

/* Forms (Options page) */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 13px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 200px;
  resize: vertical;
}

.form-group .help-text {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Toggle switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Popup specific */
.popup-body {
  width: 320px;
  min-height: 200px;
}

.popup-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--bg);
}

.popup-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.popup-status-dot.inactive {
  background: var(--text-light);
}

.popup-links {
  padding: 8px;
}

.popup-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.popup-link:hover {
  background: var(--bg);
}

/* Options page specific */
.options-body {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
}

.options-section {
  margin-bottom: 32px;
}

.options-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--bg);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* Hidden utility */
.hidden {
  display: none !important;
}
