:root {
  --primary-color: #0c5d90;
  --secondary-color: #28a745;
  --danger-color: #dc3545;
  --light-bg: #f9f9f9;
  --border-color: #ccc;
  --border-radius: 0.25rem;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --shadow: 0 2px 5px rgb(0 0 0 / 0.15);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: var(--spacing-sm);
  background: var(--light-bg);
  font-size: 12px;
  line-height: 1.3;
}

.app-container {
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  overflow-x: hidden;
  box-sizing: border-box;
}

.sharepoint-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: #fff;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.sharepoint-toolbar .toolbar-primary,
.sharepoint-toolbar .toolbar-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  align-items: center;
  justify-content: space-between;
}

.sharepoint-toolbar .file-id-field {
  display: flex;
  flex-direction: column;
  min-width: 14rem;
  flex: 1 1 20rem;
}

.sharepoint-toolbar .toolbar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

.sharepoint-toolbar .status-line {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.status-chip {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.status-chip.ok {
  background: #e7f5ee;
  color: #1f7a4d;
  border-color: #afe4c8;
}

.status-chip.busy {
  background: #fff5e6;
  color: #a8600c;
  border-color: #f6c78f;
}

.status-chip.error {
  background: #fdecec;
  color: #a12626;
  border-color: #f2a2a2;
}

.status-chip.locked {
  background: #fff3cd;
  color: #9c6500;
  border-color: #ffe8a1;
}

.status-chip.unlocked,
.status-chip.available {
  background: #e7f5ee;
  color: #1f7a4d;
  border-color: #afe4c8;
}

.status-text {
  color: #444;
  font-size: 0.95rem;
}

.project-info {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.project-info input {
  flex: 1 1 15rem;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-sizing: border-box;
  min-width: 0;
}

.total-all {
  background: var(--primary-color);
  color: black;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  font-weight: bold;
  box-shadow: var(--shadow);
  z-index: 2;
  user-select: none;
  margin-bottom: var(--spacing-lg);
  overflow-x: auto;
}

.total-all table {
  border-collapse: collapse;
}

.total-all th {
  color: black !important;
}

.total-all th,
.total-all td {
  border: none;
  padding: 2px 6px;
  color: white;
  text-align: right;
}

.total-all th:first-child,
.total-all td:first-child {
  text-align: left;
}

button {
  margin: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--border-radius);
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary-color) 85%, white);
}

button:disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 0.7;
}

.groups-container {
  display: grid;
  width: 100%;
}

.group-wrapper {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--spacing-sm);
  position: relative;
  background: white;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-sm);
  width: 100%;
  box-sizing: border-box;
}

.task-lists-container {
  display: grid;
  gap: var(--spacing-xs);
  width: 100%;
  position: relative;
}

.tasklist-wrapper {
  display: flex;
  gap: var(--spacing-xs);
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  position: relative;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: var(--spacing-xs);
  margin: var(--spacing-xs) 0;
}

.add-above, .add-below,
.add-list-above, .add-list-below,
.add-group-above, .add-group-below {
  position: absolute;
  left: -0.75rem;
  background: var(--secondary-color);
  color: white;
  border-radius: 50%;
  width: 1.1rem;
  height: 1.1rem;
  line-height: 1.1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  display: none;
  box-shadow: var(--shadow);
  z-index: 2;
  transition: transform 0.2s ease;
}

.add-above, .add-list-above, .add-group-above {
  top: 0.25rem;
}

.add-below, .add-list-below, .add-group-below {
  bottom: 0.25rem;
}

.add-above:hover, .add-below:hover,
.add-list-above:hover, .add-list-below:hover,
.add-group-above:hover, .add-group-below:hover {
  transform: scale(1.3);
  background: color-mix(in srgb, var(--secondary-color) 85%, white);
}

.tasklist-wrapper:hover .add-list-above,
.tasklist-wrapper:hover .add-list-below {
  display: block;
}

.tasklist-header {
  flex-basis: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  background: #fff;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
}

.tasklist-content {
  flex: 1;
}

.tasklist-name-input {
  font-size: 0.95em;
  font-weight: 600;
  padding: 2px 4px;
  min-width: 0;
  max-width: 140px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: white;
  field-sizing: fixed;
  font-family: inherit;
}

.tasklist-drag-handle {
  cursor: move;
  padding: 4px 8px;
  color: #6c757d;
  font-size: 18px;
  user-select: none;
}

.add-tasklist-btn {
  margin-left: auto;
  background: #28a745;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.group-footer {
  display: flex;
  justify-content: end;
  text-align: right;
}

.tasklist-total {
  background: #e9ecef !important;
  font-weight: 600;
}

.group-total {
  font-size: 1.1em;
  font-weight: 700;
  color: #0c5d90;
}

.hidden-input {
  display: none;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

.project-list-page {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-md);
}

.project-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.project-list-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.project-list-section {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
}

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

.project-cards {
  list-style: none;
  padding: 0;
  margin: var(--spacing-sm) 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid #e0e0e0;
  border-radius: 0;
  background: #fff;
  gap: var(--spacing-md);
  transition: background-color 0.15s ease;
}

.project-card:hover {
  background: #f5f5f5;
}

.project-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

.project-card p {
  margin: 2px 0 0 0;
  font-size: 11px;
  color: #666;
}

.project-link {
  background: var(--secondary-color);
  color: white;
  text-decoration: none;
  padding: 4px 12px;
  border-radius: var(--border-radius);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}

.project-link:hover {
  background: color-mix(in srgb, var(--secondary-color) 85%, white);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--spacing-md) 0;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--light-bg);
}

.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: var(--light-bg);
}

.table-responsive::-webkit-scrollbar-thumb {
  background-color: var(--primary-color);
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Colonnes responsives */
.col-drag { width: 4%; }
.col-task { width: 25%; }
.col-time { width: 7%; }
.col-department { width: 12%; }
.col-confidence { width: 7%; }
.col-risk-time { width: 7%; }
.col-enabled { width: 5%; }
.col-comment { width: 1fr; min-width: 15%; }
.col-actions { width: 7%; }

/* Colonnes pour la section achat */
.col-name { width: 25%; }
.col-amount { width: 100px; }

/* Table en lecture seule */
.readonly-table {
  max-width: 600px;
}

.readonly-table th,
.readonly-table td {
  width: 100%;
  min-width: 0;
}

/* Classes utilitaires */
.hidden {
  visibility: hidden;
}

.purchase-section {
  border: 2px solid var(--primary-color);
}

th, td {
  border: 1px solid var(--border-color);
  padding: 2px 4px;
  text-align: left;
  vertical-align: middle;
  word-wrap: break-word;
  min-width: 6rem;
}

th {
  background: #ddebf7;
  position: sticky;
  top: 0;
  z-index: 1;
}

@media (max-width: 768px) {
  .app-container {
    padding: 0 var(--spacing-sm);
    max-width: 100%;
    overflow-x: hidden;
  }

  .button-group {
    flex-direction: column;
    width: 100%;
  }

  .button-group button {
    width: 100%;
    margin: var(--spacing-xs) 0;
  }

  .task_groups_table {
    font-size: 0.875rem;
    width: 100%;
  }
  
  .table-responsive {
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
  }

  th, td {
    padding: var(--spacing-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  td:not(.drag-cell) {
    min-width: 120px;
  }

  .task-cell input,
  td input[type="number"],
  td input[type="text"],
  td select {
    padding: var(--spacing-xs);
    font-size: 0.875rem;
    width: 100%;
    min-width: 0;
  }

  .remove-crossbutton {
    padding: var(--spacing-xs);
    min-width: 1.5rem;
    white-space: nowrap;
  }

  .group-header {
    flex-direction: column;
    gap: var(--spacing-sm);
    width: 100%;
  }

  .group-move-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .group-name-input {
    width: 100%;
  }

  .group-wrapper {
    padding: var(--spacing-sm);
    margin: var(--spacing-sm) 0;
  }
}

@media (max-width: 480px) {
  body {
    padding: var(--spacing-sm);
  }

  .project-info {
    flex-direction: column;
  }

  .total-all {
    font-size: 0.875rem;
  }
}

.task-row {
  position: relative;
}

.task-cell {
  position: relative;
}



.drag-cell {
  width: 24px;
  text-align: center;
  cursor: move;
  user-select: none;
  color: #777;
  font-size: 18px;
}

.drag-handle {
  cursor: move;
}

.group-header {
  display: flex;
  /*align-items: center;*/
  flex-direction: column;
  gap: var(--spacing-sm);
  background: #f8f9fa;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius);
}

.group-move-buttons {
  display: flex;
  flex-direction: row;
  gap: 2px;
  margin-right: 8px;
}

.group-move-button {
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 24px;
  height: 24px;
  margin: auto 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #777;
  font-size: 14px;
  transition: background-color 0.2s;
}

.group-move-button:hover {
  background: #e0e0e0;
}

.group-move-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f0f0f0;
}

input[type=text], 
input[type=number], 
select {
  width: 100%;
  padding: 1px 3px;
  font-size: 0.95em;
  box-sizing: border-box;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: white;
  transition: border-color 0.2s ease;
  height: 20px;
}

input[type=text]:focus, 
input[type=number]:focus, 
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(12, 93, 144, 0.1);
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.remove-crossbutton {
  background: var(--danger-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  font-weight: 700;
  user-select: none;
  transition: background-color 0.2s ease;
}

.remove-crossbutton:hover {
  background: color-mix(in srgb, var(--danger-color) 85%, white);
}

tfoot tr td {
  text-align: right;
  font-weight: bold;
  background: #fafafa;
}
/* Les textarea des titres d'achats et de tâches occupent 100% de la largeur de leur cellule et ne débordent pas */
td textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  max-width: 100%;
  min-width: 0;
  display: block;
  field-sizing: content;
  font-family: inherit;
}

.task-row:hover .add-above,
.task-row:hover .add-below,
.tasklist-wrapper:hover .add-list-above,
.tasklist-wrapper:hover .add-list-below,
.group-wrapper:hover .add-group-above,
.group-wrapper:hover .add-group-below {
  display: inline-block;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  background: #f5f5f5;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3em;
  color: var(--primary-color);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: black;
}

.modal-body {
  padding: var(--spacing-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: #333;
}

.form-group select,
.form-group input[type="text"] {
  padding: var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.95em;
  font-family: inherit;
  background: white;
}

.form-group select:focus,
.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(12, 93, 144, 0.1);
}

.form-group select:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  color: #999;
}

.form-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
  margin-top: var(--spacing-lg);
}

.btn-primary,
.btn-secondary {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  user-select: none;
}

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

.btn-primary:hover {
  background: color-mix(in srgb, var(--primary-color) 85%, white);
}

.btn-primary:active {
  background: color-mix(in srgb, var(--primary-color) 70%, black);
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

/* Site/Drive Selector */
.site-drive-selector {
  display: none;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: #f9f9f9;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #e0e0e0;
}

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: #f9f9f9;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #e0e0e0;
}

.breadcrumb-nav span {
  color: #555;
  font-weight: 500;
  font-size: 12px;
}

.selection-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: #eef6ff;
}

.selection-info[hidden] {
  display: none;
}

.selection-info-text {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.selection-info-text p {
  margin: 0;
  font-size: 0.95em;
  color: #1f3b57;
}

.selector-group {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
}

.selector-group label {
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: #333;
  font-size: 0.9em;
}

.selector-group .select-search {
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9em;
  font-family: inherit;
}

.selector-group .select-search:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(12, 93, 144, 0.1);
}

.selector-group select {
  padding: var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9em;
  font-family: inherit;
  background: white;
}

.selector-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(12, 93, 144, 0.1);
}

.selector-group select:disabled {
  background: #e0e0e0;
  cursor: not-allowed;
  color: #999;
}

/* Folder List Container */
.folder-list-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: white;
}

.folder-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

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

.folder-item:hover {
  background: #f8f9fa;
}

.folder-item.selected {
  background: #e3f2fd;
  border-left: 3px solid var(--primary-color);
}

.folder-item.root-folder {
  background: #fff9e6;
  font-weight: 600;
}

.folder-item.root-folder:hover {
  background: #fff3cc;
}

.folder-item.empty {
  justify-content: center;
  color: #999;
  font-style: italic;
  cursor: default;
}

.folder-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex: 1;
}

.folder-icon {
  font-size: 1.2em;
}

.folder-name {
  font-size: 0.95em;
  color: #333;
}

.folder-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.folder-open-btn,
.folder-select-btn {
  padding: var(--spacing-xs) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: white;
  color: #333;
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.folder-open-btn:hover {
  background: #f0f0f0;
}

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

.folder-select-btn:hover {
  background: color-mix(in srgb, var(--primary-color) 85%, white);
}

/* Folder Breadcrumb in Modal */
.folder-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: #f9f9f9;
  border-radius: var(--border-radius);
  font-size: 0.9em;
}

.breadcrumb-back {
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: white;
  color: #333;
  font-size: 0.85em;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.breadcrumb-back:hover {
  background: #e0e0e0;
}

.breadcrumb-path {
  color: #555;
  font-weight: 500;
}

