/* public/css/style.css */
@import url('colors.css');

/* Prevent page shift when modals open/close */
html {
  overflow-y: scroll !important;
}
body {
  padding-right: 0 !important;
}
body.modal-open {
  overflow: auto !important;
  padding-right: 0 !important;
}

/* ==========================================
   DESIGN SYSTEM - Variables globales partagées
   ========================================== */
:root {
  /* Tailles de police (4 niveaux) */
  --font-size-sm: 12px;    /* Labels, badges, texte secondaire */
  --font-size-base: 14px;  /* Texte principal, inputs, contenu */
  --font-size-lg: 16px;    /* Sous-titres, éléments importants */
  --font-size-xl: 22px;    /* Titres, nom/prénom */

  /* Espacements cohérents */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;

  /* Border radius 
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;*/

    /* Border radius */
  --radius-sm: 1px;
  --radius-md: 2px;
  --radius-lg: 4px;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
}

.table th {
  background-color: var(--bg-subtle);
}

.table td {
  vertical-align: middle;
}

.card {
  box-shadow: 0 0.125rem 0.25rem var(--shadow-dark);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card-header {
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--shadow-dark);
}

.card-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

/* ===========================================
   SHARED STYLES - Action column (list tables)
   Used in: leads, companies, deals, index
   =========================================== */

.action-cell {
  width: 105px !important;
  min-width: 105px !important;
  white-space: nowrap;
  vertical-align: middle !important;
  text-align: center !important;
}

.status-cell {
  width: 105px !important;
  min-width: 105px !important;
  text-align: center !important;
  vertical-align: middle !important;
}
.action-cell .btn-group-action {
  display: inline-flex;
  gap: 3px;
  justify-content: center;
}

/* ===========================================
   SHARED STYLES - Bulk Operations (Danger Zone)
   Used in: index, leads, companies, deals, tasks
   =========================================== */

/* .danger-zone-active: background removed intentionally - no visual change on container */

.select-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  vertical-align: middle;
}

.select-checkbox-cell {
  width: 40px;
}

/* Lock Zone Styles */
.lock-zone-active {
  background-color: var(--bg-lock-zone) !important;
  transition: background-color 0.3s ease;
}

/* ===========================================
   SHARED STYLES - Highlight Changed Fields
   Used in: lead, deal
   =========================================== */

.highlight-changed {
  border: 2px solid var(--color-primary) !important;
  border-radius: 6px !important;
  background-color: rgba(13, 110, 253, 0.06) !important;
}

/* ===========================================
   SHARED STYLES - Pipeline/Kanban View
   Used in: deals, pipeline
   =========================================== */

.pipeline-container {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: calc(100vh - 280px);
}

.pipeline-column {
  flex: 1;
  min-width: 180px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
}

.pipeline-column-header {
  padding: var(--spacing-md);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipeline-column-header .stage-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.pipeline-column-header .stage-total {
  font-size: 0.9rem;
  font-weight: 500;
}

.pipeline-column-header .stage-count {
  font-size: 0.75rem;
  opacity: 0.85;
}

.pipeline-column-body {
  padding: 8px;
  flex: 1;
  overflow-y: auto;
}

/* Pipeline column colors - Soft Outline */
.column-qualified .pipeline-column-header { background-color: #eff6ff; border: 2px solid #bfdbfe; color: #1d4ed8; }
.column-proposal .pipeline-column-header  { background-color: #fffbeb; border: 2px solid #fde68a; color: #b45309; }
.column-won .pipeline-column-header       { background-color: #fef2f2; border: 2px solid #fecaca; color: #b91c1c; }
.column-lost .pipeline-column-header      { background-color: #f8fafc; border: 2px solid #e2e8f0; color: #334155; }

.empty-column {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 20px 10px;
}

/* ===========================================
   SHARED STYLES - Deal Cards (Pipeline)
   Used in: deals, pipeline
   =========================================== */

.deal-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
  border: var(--border-width) solid var(--border-color);
}

.deal-card:hover {
  background-color: var(--bg-hover);
  border-color: var(--color-primary);
  color: inherit;
}

.deal-card.hidden {
  display: none;
}

.deal-card-name {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.deal-card-company {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.deal-card-amount {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ===========================================
   SHARED STYLES - Task Indicators
   Used in: deals, pipeline
   =========================================== */

.task-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.task-indicator.overdue { background-color: var(--task-overdue); }
.task-indicator.today { background-color: var(--task-today); }
.task-indicator.week { background-color: var(--task-week); }
.task-indicator.after { background-color: var(--task-after); }
.task-indicator.none { background-color: var(--task-none); }

/* ===========================================
   SHARED STYLES - Accordion/History
   Used in: lead, deal
   =========================================== */

.accordion-button:not(.collapsed) {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.accordion-button {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}

.accordion-button:focus {
  box-shadow: none;
  border-color: var(--shadow-dark);
}

.history-note {
  white-space: pre-wrap;
  background-color: var(--bg-card);
  padding: var(--spacing-lg);
  border-radius: var(--radius-sm);
  margin-top: var(--spacing-md);
  font-size: var(--font-size-base);
}

/* ===========================================
   SHARED STYLES - Buttons
   Used in: all pages
   =========================================== */

.btn-revert {
  background-color: var(--color-danger);
  color: var(--text-white);
  font-weight: var(--font-weight-medium);
  border: none;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
}

.btn-revert:hover {
  background-color: var(--color-danger);
  color: var(--text-white);
  opacity: 0.85;
}

/* ===========================================
   SHARED STYLES - Labels & Badges
   Used in: lead, deal, all pages
   =========================================== */

.section-label {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-xs);
}

.select-label {
  font-size: var(--font-size-sm);
}

.badge-outline-secondary {
  border: var(--border-width) solid var(--text-secondary);
  color: var(--text-secondary);
  background-color: transparent;
}

/* ===========================================
   SHARED STYLES - Form Controls
   Used in: all pages
   =========================================== */

.form-control-sm,
.form-select-sm {
  font-size: var(--font-size-base);
  padding: var(--spacing-sm) var(--spacing-md);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

/* Badges uniformes */
.badge {
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
}

.badge-sm {
  font-size: var(--font-size-sm);
}

/* ===========================================
   SHARED STYLES - Utility Classes
   Used in: multiple views
   =========================================== */

/* Card pour recherche/filtres */
.card-search {
  background-color: var(--bg-card);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: none;
  overflow: visible;
}

/* Table wrapper: fond blanc + border-radius identique à la navbar */
.table-card {
  background-color: var(--bg-card);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}
.table-card .table {
  margin-bottom: 0;
}

/* Truncation helper for table cells */
.truncate-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===========================================
   SHARED STYLES - AI Save Toast Notification
   =========================================== */
.ai-save-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background-color: var(--color-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(13, 110, 253, 0.25);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}
.ai-save-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ai-save-toast .toast-undo-btn {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.7);
  color: #fff;
  border-radius: 5px;
  padding: 2px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}
.ai-save-toast .toast-undo-btn:hover {
  background: rgba(255,255,255,0.18);
}

/* Highlight pour petits changements */
.highlight-changed-sm {
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Background pour zones d'édition */
.bg-edit {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

/* ===========================================
   SHARED STYLES - Custom Info Cards
   Used in: lead, deal
   =========================================== */

.custom-info-card {
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  position: relative;
}

.custom-info-card.empty {
  border: var(--border-width) dashed var(--border-color);
}

.custom-info-card.filled {
  border: var(--border-width) solid var(--border-color);
}

.custom-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.custom-info-label {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.custom-info-value {
  color: var(--text-primary);
  font-size: var(--font-size-base);
  white-space: pre-wrap;
  line-height: 1.5;
}

.custom-info-edit-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.custom-info-card:hover .custom-info-edit-icon {
  opacity: 1;
}

.custom-info-edit-icon:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.custom-info-input {
  width: 100%;
  min-height: 80px;
  padding: var(--spacing-sm);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  resize: vertical;
}

.custom-info-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--shadow-focus);
}

/* ===========================================
   SHARED STYLES - History Entries
   Used in: lead, deal
   =========================================== */

.history-entry {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  border-left: 4px solid var(--text-secondary);
}

.history-entry:first-child {
  background-color: var(--bg-history-first);
  border-left: 4px solid var(--color-primary);
}

.edit-summary-btn {
  position: relative;
  z-index: 10;
}

.history-edit-form {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  margin-top: var(--spacing-md);
}

.history-edit-form label {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-xs);
}

.history-edit-form .form-control {
  font-size: var(--font-size-base);
}

.history-edit-form textarea {
  resize: vertical;
  min-height: 80px;
}

.edit-history-btn {
  display: inline-flex;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  align-items: center;
  gap: var(--spacing-xs);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s, color 0.2s;
}

.edit-history-btn:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.edit-history-btn svg {
  pointer-events: none;
}

.delete-history-btn {
  color: var(--color-danger);
}

.delete-history-btn:hover {
  background-color: var(--bg-danger-light);
  color: var(--color-danger);
}

/* ===========================================
   SHARED STYLES - Toggle Cards
   Used in: lead, deal
   =========================================== */

.toggle-card .toggle-header {
  padding: var(--spacing-sm) 0;
}

.toggle-card .toggle-content {
  padding-top: var(--spacing-sm);
}

.toggle-content {
  transition: all 0.3s ease;
}

/* ===========================================
   SHARED STYLES - AI Input Group
   Used in: lead, deal
   =========================================== */

.ai-input-wrapper {
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

@media (min-width: 768px) {
  .ai-input-wrapper {
    max-width: 85%;
  }
}

.custom-input-group {
  border: var(--border-width) solid var(--border-color);
  border-radius: 24px;
  padding: var(--spacing-md) var(--spacing-lg);
  transition: border-color 0.2s;
  background-color: var(--bg-card);
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow-input);
}

.custom-input-group:focus-within {
  border-color: var(--border-focus);
}

.custom-input-group input,
.custom-input-group textarea {
  border: none;
  box-shadow: none !important;
  color: var(--text-primary);
  background: transparent;
  flex: 1;
  font-size: var(--font-size-base);
  resize: none;
  font-family: inherit;
  line-height: 1.5;
}

.custom-input-group input::placeholder,
.custom-input-group textarea::placeholder {
  color: var(--text-secondary);
}

.custom-input-group input:focus,
.custom-input-group textarea:focus {
  outline: none;
  z-index: 0;
}

.ai-textarea-auto-resize {
  min-height: 24px;
  max-height: 200px;
  overflow-y: hidden;
}

.btn-send {
  width: 45px;
  height: 45px;
  border-radius: 50% !important;
  background-color: var(--text-primary) !important;
  color: var(--text-white) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  flex-shrink: 0;
  margin-left: var(--spacing-sm);
  z-index: 10;
}

.btn-send:hover {
  opacity: 0.8;
}

/* ===========================================
   SHARED STYLES - Horizontal Stage Pipeline
   Used in: lead, deal
   =========================================== */

.stage-pipeline-top {
  position: relative;
  margin-bottom: 0;
}

.status-pipeline-horizontal {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: var(--spacing-md);
  max-width: fit-content;
}

.status-item-horizontal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  flex: 1;
  min-width: 80px;
  position: relative;
}

.status-item-horizontal:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 100%;
  height: 2px;
  background-color: var(--border-color);
  z-index: 0;
}

.status-item-horizontal.passed:not(:last-child)::after {
  background-color: var(--text-primary);
}

.status-circle-horizontal {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--border-color);
  border: 2px solid var(--border-color);
  position: relative;
  z-index: 1;
}

.status-item-horizontal.active .status-circle-horizontal {
  background-color: var(--color-accent);
  border-color: var(--text-primary);
}

.status-item-horizontal.passed .status-circle-horizontal {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
}

.status-text-horizontal {
  font-size: var(--font-size-sm);
  color: var(--border-color);
  text-align: center;
  white-space: nowrap;
  font-style: normal;
}

.status-item-horizontal.active .status-text-horizontal {
  color: var(--text-primary);
  font-weight: var(--font-weight-black);
  font-style: normal;
}

.status-item-horizontal.passed .status-text-horizontal {
  color: var(--text-primary);
}

/* Stage Pipeline Editable */
.status-pipeline-horizontal.editable .status-item-horizontal {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.status-pipeline-horizontal.editable .status-item-horizontal:hover {
  transform: scale(1.05);
}

.status-pipeline-horizontal.editable .status-item-horizontal:hover .status-circle-horizontal {
  box-shadow: 0 0 0 3px var(--shadow-focus-strong);
}

.status-pipeline-horizontal.editable .status-circle-horizontal {
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

/* ===========================================
   SHARED STYLES - Next Action Minimal
   Used in: lead, deal
   =========================================== */

.next-action-minimal {
  background-color: var(--bg-card);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  transition: border-color 0.2s ease;
}

.next-action-minimal:hover {
  border-color: var(--color-accent);
}

.next-action-minimal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.next-action-content {
  flex: 1;
}

.next-action-label {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-weight: var(--font-weight-normal);
}

.next-action-date-badge {
  background-color: var(--color-accent);
  color: var(--text-white);
  padding: 2px var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
}

.next-action-title {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--spacing-xs);
}

.next-action-description {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
}

.next-action-minimal .toggle-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-top: 2px;
}

.next-action-minimal.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* ===========================================
   SHARED STYLES - Pencil/Edit Icons
   Used in: lead, deal
   =========================================== */

.pencil-edit-icon,
.lead-edit-icon {
  background: none;
  border: none;
  padding: var(--spacing-xs);
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.2s;
}

.pencil-edit-icon:hover,
.lead-edit-icon:hover {
  color: var(--color-primary);
  opacity: 1;
}

/* ===========================================
   SHARED STYLES - Inline Editing
   Used in: lead, deal
   =========================================== */

.inline-edit-h1 {
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--color-primary);
  padding: 0;
  margin: 0;
  outline: none;
  width: auto;
  min-width: 50px;
  max-width: 200px;
  line-height: inherit;
  display: inline-block;
}

.inline-edit-h1:focus {
  border-bottom-color: var(--color-primary);
}

/* ===========================================
   SHARED STYLES - Icon Buttons (uniform border-radius)
   Used in: lead, deal pages
   =========================================== */

/* All small icon-style action buttons share the same border-radius */
.btn-sm.btn-outline-secondary,
.btn-sm.btn-outline-danger,
.btn-sm.btn-outline-primary,
.btn-sm.btn-outline-warning,
.btn-sm.btn-outline-success {
  border-radius: 6px !important;
}

/* ===========================================
   SHARED STYLES - Tags (pill design)
   Used in: lead, deal pages
   =========================================== */

.tag-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  background-color: #f3f4f6;
  color: #4b5563;
  line-height: 1.5;
}

/* ===========================================
   SHARED STYLES - Quick Action Pills
   Used in: lead page (note templates)
   =========================================== */

.quick-actions-wrapper {
  max-width: 85%;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.quick-actions-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.quick-action-pill {
  border-radius: 20px !important;
  padding: 3px 12px !important;
  font-size: var(--font-size-sm) !important;
  background-color: var(--bg-subtle) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-secondary) !important;
  transition: all 0.15s ease !important;
}

.quick-action-pill:hover {
  background-color: var(--border-color) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

/* ===========================================
   SHARED STYLES - Add field link (empty data)
   Used in: lead contact info section
   =========================================== */

.add-field-link {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
}

.add-field-link:hover {
  color: var(--color-primary);
}

/* Lead header - name hierarchy (typography defined in lead-deal.css) */
.lead-header-name {
  color: var(--text-primary);
  margin-bottom: 2px;
}

.lead-header-name .lead-lastname-upper {
  text-transform: uppercase;
}

.lead-header-sub {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-top: 2px;
}

.lead-name-container {
  display: block;
}
