/* ==========================================================================
   PROJECT MANAGEMENT STYLES
   ========================================================================== */

/* Project Management */
.project-item {
  border-left: 4px solid transparent;
  transition: border-color 0.2s ease;
}

.project-item[data-project-type="construction"] { 
  border-left-color: #10b981; 
}

.project-item[data-project-type="renovation"] { 
  border-left-color: #f59e0b; 
}

.project-item[data-project-type="sav"] {
  border-left-color: #ef4444;
}

.project-item[data-project-type="joinery"] {
  border-left-color: #8b5cf6; /* Purple for joinery */
}

/* Phase Type Colors (for planning calendar) */
.phase-study,
.phase-etude {
  background-color: #dbeafe !important;
  border-left: 3px solid #1e40af !important;
}

.phase-procurement,
.phase-approvisionnement {
  background-color: #fce7f3 !important;
  border-left: 3px solid #be185d !important;
}

.phase-manufacturing,
.phase-fabrication {
  background-color: #d1fae5 !important;
  border-left: 3px solid #065f46 !important;
}

.phase-delivery,
.phase-livraison {
  background-color: #e0e7ff !important;
  border-left: 3px solid #4338ca !important;
}

.phase-installation,
.phase-pose {
  background-color: #fef3c7 !important;
  border-left: 3px solid #92400e !important;
}

.phase-snagging,
.phase-finitions {
  background-color: #fce4ec !important;
  border-left: 3px solid #c62828 !important;
}

/* Phase Management */
.phases-list {
  display: grid;
  gap: 1rem;
}

.phase-card,
.phase-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--gray-50);
}

.phase-card {
  background: white;
  margin-bottom: 0;
}

.phase-item:last-child {
  margin-bottom: 0;
}

.phase-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.phase-title-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.phase-title-section h4 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.phase-dates {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: right;
}

.phase-description {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.phase-progress {
  margin-bottom: 0.75rem;
}

.phase-progress label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  display: block;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--primary);
  transition: width 0.3s ease;
}

.phase-assignments {
  border-top: 1px solid var(--gray-100);
  padding-top: 0.75rem;
}

.phase-assignments h5 {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.assignment-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.phase-actions {
  display: flex;
  gap: 0.5rem;
}

/* Subcontractor Management */
.subcontractors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.subcontractor-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: white;
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.sub-header h4 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.sub-company {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.sub-contact {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.sub-notes {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-style: italic;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--gray-50);
  border-radius: 4px;
}

.sub-actions {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--gray-100);
  padding-top: 0.75rem;
}

/* Groups Section Styles */
.groups-container {
  margin-top: 0.5rem;
}

.group-section {
  margin-bottom: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  overflow: hidden;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background-color: #f9fafb;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
  border-bottom: 1px solid #e5e7eb;
}

.group-header:hover {
  background-color: #f3f4f6;
}

.group-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: #374151;
}

.group-arrow {
  font-size: 0.75rem;
  color: #6b7280;
  transition: transform 0.15s ease-in-out;
  user-select: none;
}

.group-content {
  padding: 0.5rem 0;
  background-color: #ffffff;
  transition: max-height 0.2s ease-in-out, opacity 0.2s ease-in-out;
  max-height: 500px;
  opacity: 1;
}

.group-content.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

.component-item {
  display: flex;
  align-items: flex-start;
  padding: 0.5rem 1rem 0.5rem 2rem;
  border-left: 2px solid #e5e7eb;
  margin-left: 1rem;
}

.component-item:hover {
  background-color: #f9fafb;
}

.component-icon {
  font-size: 0.875rem;
  margin-right: 0.75rem;
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.component-info {
  flex: 1;
}

.component-name {
  font-size: 0.875rem;
  color: #374151;
  font-weight: 400;
  line-height: 1.25;
}

.component-formula {
  font-size: 0.75rem;
  color: #6b7280;
  font-family: 'Courier New', monospace;
  margin-top: 0.125rem;
}

/* Conditional Components Styles */
.condition-section {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
  transition: all 0.2s ease;
}

.condition-section:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.condition-section .component-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
  color: #475569;
}

.help-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.help-btn:hover {
  color: #3b82f6;
  background: #eff6ff;
  transform: scale(1.1);
}

/* Enhanced Condition Type Select */
.condition-type-select {
  margin-bottom: 12px;
  border: 2px solid #e2e8f0;
  transition: all 0.2s ease;
}

.condition-type-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Condition Expression Container with Animation */
.condition-expression-container {
  overflow: hidden;
  transition: all 0.3s ease;
}

.condition-expression-container.hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
}

.condition-expression-container:not(.hidden) {
  max-height: 300px;
  opacity: 1;
  margin-top: 8px;
}

/* Enhanced Condition Input Wrapper */
.condition-input-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  margin-bottom: 8px;
}

.condition-expression {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
  font-size: 13px;
  background: #ffffff;
  border: 2px solid #d1d5db;
  border-radius: 6px 0 0 6px;
  border-right: none;
  flex: 1;
  transition: all 0.2s ease;
  padding: 10px 12px;
}

.condition-expression:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.condition-expression::placeholder {
  color: #9ca3af;
  font-style: italic;
}

/* Test Button */
.condition-test-btn {
  background: #3b82f6;
  color: white;
  border: 2px solid #3b82f6;
  border-radius: 0 6px 6px 0;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  min-width: 44px;
}

.condition-test-btn:hover {
  background: #2563eb;
  border-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.condition-test-btn:active {
  transform: translateY(0);
}

/* Enhanced Validation Results */
.condition-validation-result {
  margin-top: 8px;
  margin-bottom: 8px;
}

.condition-validation {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid;
  transition: all 0.2s ease;
}

.condition-validation.success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  border-color: #a7f3d0;
}

.condition-validation.error {
  background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
  color: #991b1b;
  border-color: #fca5a5;
}

.condition-validation.warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
  color: #92400e;
  border-color: #fcd34d;
}

.condition-validation.loading {
  background: linear-gradient(135deg, #e0f2fe 0%, #7dd3fc 100%);
  color: #0c4a6e;
  border-color: #7dd3fc;
}

/* Condition Description Input */
.condition-description {
  font-size: 13px;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.condition-description:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Enhanced Condition Help */
.condition-help {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 6px;
  padding: 12px;
}

.condition-help small {
  line-height: 1.5;
  color: #64748b;
}

.condition-help-item {
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
  margin-bottom: 8px;
  border-left: 4px solid #3b82f6;
}

/* Clickable Examples */
.condition-example {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  margin: 2px 0;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.condition-example:hover {
  background: #dbeafe;
  border-color: #3b82f6;
  transform: translateX(4px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .subcontractors-grid {
    grid-template-columns: 1fr;
  }
  
  .phase-header {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .phase-dates {
    text-align: left;
  }
  
  .group-header {
    padding: 0.5rem 0.75rem;
  }
  
  .group-name {
    font-size: 0.8125rem;
  }
  
  .component-item {
    padding: 0.375rem 0.75rem 0.375rem 1.5rem;
    margin-left: 0.75rem;
  }
  
  .component-name {
    font-size: 0.8125rem;
  }
  
  .component-formula {
    font-size: 0.6875rem;
  }
  
  .condition-input-wrapper {
    flex-direction: column;
  }
  
  .condition-expression {
    border-radius: 6px 6px 0 0;
    border-right: 2px solid #d1d5db;
  }
  
  .condition-test-btn {
    border-radius: 0 0 6px 6px;
    border-top: none;
  }
}

/* ==========================================================================
   PLANNING CONFIGURATION STYLES
   ========================================================================== */

/* Schedule Table */
.schedule-table {
  min-width: auto;
}

.schedule-table th {
  text-align: center;
}

.schedule-table th:first-child {
  text-align: left;
}

.schedule-table td {
  text-align: center;
  vertical-align: middle;
}

.schedule-table td:first-child {
  text-align: left;
}

.schedule-table .form-input-sm {
  width: 100%;
  max-width: 120px;
  text-align: center;
}

.schedule-table .form-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

/* Absence Cards */
.absence-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  transition: all 0.2s ease;
}

.absence-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.absence-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.absence-card-name {
  font-weight: 600;
  color: var(--text);
}

.absence-card-dates {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.absence-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* Absence Type Badges */
.absence-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.absence-badge.vacation {
  background: #dbeafe;
  color: #1e40af;
}

.absence-badge.sick_leave {
  background: #fee2e2;
  color: #991b1b;
}

.absence-badge.training {
  background: #e0e7ff;
  color: #4338ca;
}

.absence-badge.public_holiday {
  background: #f3e8ff;
  color: #6b21a8;
}

.absence-badge.other {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* Team Cards */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.team-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--surface);
  transition: all 0.2s ease;
}

.team-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.team-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.team-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.team-card-function {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.team-card-description {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.team-card-actions {
  display: flex;
  gap: 0.5rem;
}

/* Team Members */
.team-members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.team-members-title {
  width: 100%;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.member-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.member-badge:hover {
  background: var(--gray-200);
}

.member-badge-name {
  color: var(--text);
}

.member-badge-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.member-badge button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--error);
  padding: 0;
  margin-left: 0.25rem;
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.member-badge button:hover {
  opacity: 1;
}

/* Function Badges */
.function-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Colors mirror phase colors in my-planning.css — single source of truth */
.function-badge.study {
  background: rgba(59, 130, 246, 0.15);   /* phase-etude #3b82f6 */
  color: #1d4ed8;
}

.function-badge.preparation {
  background: rgba(190, 24, 93, 0.15);    /* phase-approvisionnement #be185d */
  color: #be185d;
}

.function-badge.fabrication {
  background: rgba(245, 158, 11, 0.15);   /* phase-fabrication #f59e0b */
  color: #92400e;
}

.function-badge.installation {
  background: rgba(16, 185, 129, 0.15);   /* phase-pose #10b981 */
  color: #065f46;
}

.function-badge.execution {
  background: rgba(249, 115, 22, 0.15);   /* phase-finitions #f97316 */
  color: #9a3412;
}

.function-badge.other {
  background: rgba(99, 102, 241, 0.15);   /* phase-livraison #6366f1 */
  color: #3730a3;
}

.function-badge.both {
  background: #f3f4f6;
  color: #374151;
}

/* Mobile Responsive - Planning Configuration */
@media (max-width: 768px) {
  .teams-grid {
    grid-template-columns: 1fr;
  }

  .absence-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .absence-card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .schedule-table {
    font-size: 0.875rem;
  }

  .schedule-table .form-input-sm {
    max-width: 80px;
    padding: 0.25rem 0.5rem;
  }
}

/* ==========================================================================
   INVOICING STATS
   ========================================================================== */

.invoicing-summary {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-value.text-warning {
  color: var(--warning);
}

.stat-value.text-success {
  color: var(--success);
}

/* Invoice action buttons */
#invoice-actions .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Table total row */
.table-total-row {
  background: var(--gray-50);
  border-top: 2px solid var(--border);
}

.table-total-row td {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}