/* ============================================
   PRIMOS Component Styles
   Buttons, modals, forms, cards, badges, toasts
   ============================================ */

/* ==================== BUTTONS ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: white;
  color: #333;
  border-color: #ddd;
}

.btn-secondary:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #ccc;
}

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

.btn-success:hover:not(:disabled) {
  background: #218838;
}

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

.btn-danger:hover:not(:disabled) {
  background: #c82333;
}

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

.btn-info:hover:not(:disabled) {
  background: #3a7bc8;
}

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

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}

.save-btn {
  background: var(--color-info);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
}

.save-btn:hover {
  background: #3a7bc8;
}

.save-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ==================== STATUS BADGES ==================== */

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-inProgress { background: var(--color-warning-light); color: var(--color-warning-dark); }
.status-complete { background: var(--color-success-light); color: var(--color-success-dark); }
.status-draft { background: #e2e3e5; color: #383d41; }
.status-cancelled { background: var(--color-danger-light); color: var(--color-danger-dark); }

.engineering-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.eng-pull { background: var(--color-info-light); color: var(--color-info-dark); }
.eng-waiting { background: var(--color-warning-light); color: var(--color-warning-dark); }
.eng-received { background: var(--color-success-light); color: var(--color-success-dark); }
.eng-complete { background: #cce5ff; color: #004085; }
.eng-none { background: #e2e3e5; color: #6c757d; }

/* Location badges */
.location-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.location-wpb {
  background: var(--color-location-wpb-bg);
  color: var(--color-location-wpb);
}

.location-tus {
  background: var(--color-location-tus-bg);
  color: var(--color-location-tus);
}

/* ==================== MODALS ==================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal);
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius-2xl);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-2xl);
}

.modal-large {
  max-width: 1100px;
}

.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 20px;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 25px;
}

.modal-footer {
  padding: 15px 25px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8f9fa;
}

/* Detail grid for modals */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.detail-section {
  background: #f8f9fa;
  padding: 15px;
  border-radius: var(--radius-lg);
}

.detail-section h3 {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: #666;
  font-size: 13px;
}

.detail-value {
  font-weight: 500;
  font-size: 14px;
}

.editable-section {
  grid-column: 1 / -1;
  background: #e8f4fd;
  border: 2px solid var(--color-info);
}

.editable-section h3 {
  color: var(--color-info);
}

/* ==================== FORMS ==================== */

.form-group {
  margin-bottom: 20px;
}

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

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-info);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.form-control:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: var(--radius-md);
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--color-info);
}

.edit-field {
  margin-bottom: 15px;
}

.edit-field label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 5px;
}

.edit-field select,
.edit-field input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: var(--radius-md);
  font-size: 14px;
}

/* ==================== CARDS ==================== */

.card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  background: #f8f9fa;
}

/* ==================== LOADING STATES ==================== */

.loading {
  text-align: center;
  padding: 50px;
  color: #666;
}

.loading-spinner {
  display: inline-block;
  font-size: 36px;
  animation: fly 1.2s ease-in-out infinite;
  margin-bottom: 10px;
}

.loading-text {
  display: block;
  color: #888;
  font-size: 14px;
  margin-top: 8px;
}

@keyframes fly {
  0%, 100% {
    transform: translateY(0) rotate(-5deg);
  }
  50% {
    transform: translateY(-8px) rotate(5deg);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ==================== TOASTS ==================== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  background: var(--color-success-light);
  border-left: 4px solid var(--color-success);
  color: var(--color-success-dark);
}

.toast.error {
  background: var(--color-danger-light);
  border-left: 4px solid var(--color-danger);
  color: var(--color-danger-dark);
}

.toast.warning {
  background: var(--color-warning-light);
  border-left: 4px solid var(--color-warning);
  color: var(--color-warning-dark);
}

.toast.info {
  background: var(--color-info-light);
  border-left: 4px solid var(--color-info);
  color: var(--color-info-dark);
}

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  font-size: 18px;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==================== EMPTY STATES ==================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.empty-state-text {
  font-size: 14px;
  color: #888;
  max-width: 400px;
  margin: 0 auto;
}

/* ==================== LINKS ==================== */

.slack-link {
  color: var(--color-info);
  text-decoration: none;
}

.slack-link:hover {
  text-decoration: underline;
}

.job-link {
  color: #333;
  text-decoration: none;
}

.job-link:hover {
  text-decoration: underline;
}

/* ==================== TOOLTIPS ==================== */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: #333;
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: var(--z-tooltip);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ==================== PROGRESS BARS ==================== */

.progress {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--color-primary);
  transition: width var(--transition-slow);
}

.progress-bar.success {
  background: var(--color-success);
}

.progress-bar.warning {
  background: var(--color-warning);
}

.progress-bar.danger {
  background: var(--color-danger);
}

/* ==================== TABS (GENERIC) ==================== */

.tabs {
  display: flex;
  border-bottom: 2px solid #eee;
  margin-bottom: 20px;
}

.tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-normal);
}

.tab:hover {
  color: #333;
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ==================== DROPDOWN ==================== */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  min-width: 160px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  padding: 8px 0;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 10px 16px;
  color: #333;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-divider {
  height: 1px;
  background: #eee;
  margin: 8px 0;
}

/* ==================== ACCORDION ==================== */

.accordion-item {
  border: 1px solid #eee;
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
}

.accordion-header {
  padding: 15px 20px;
  background: #f8f9fa;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

.accordion-header:hover {
  background: #f0f0f0;
}

.accordion-header::after {
  content: '▼';
  font-size: 10px;
  transition: transform var(--transition-normal);
}

.accordion-item.open .accordion-header::after {
  transform: rotate(180deg);
}

.accordion-body {
  display: none;
  padding: 20px;
}

.accordion-item.open .accordion-body {
  display: block;
}

    /* ============================================
       UNIFIED MODAL DESIGN SYSTEM
       Modern dark header with corner close button
       ============================================ */

    /* Base redesigned modal */
    .modal-redesign {
      max-width: 800px;
      width: 95%;
      position: relative;
      border-radius: 12px;
      overflow: hidden;
      box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }

    .modal-redesign.modal-large {
      max-width: 1100px;
    }

    .modal-redesign.modal-medium {
      max-width: 700px;
    }

    .modal-redesign.modal-small {
      max-width: 500px;
    }

    /* Dark gradient header */
    .modal-header-dark {
      background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
      color: white;
      padding: 20px 24px;
      position: relative;
    }

    .modal-header-dark .modal-close-corner {
      position: absolute;
      top: 12px;
      right: 12px;
      background: rgba(255,255,255,0.2);
      border: none;
      color: white;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      font-size: 20px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.2s;
      z-index: 10;
    }

    .modal-header-dark .modal-close-corner:hover {
      background: rgba(255,255,255,0.3);
    }

    .modal-header-dark h2 {
      font-size: 20px;
      font-weight: 700;
      margin: 0 40px 0 0;
      line-height: 1.3;
    }

    .modal-header-dark .modal-subtitle {
      font-size: 13px;
      opacity: 0.8;
      margin-top: 4px;
    }

    .modal-header-dark .modal-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      font-size: 13px;
      opacity: 0.9;
      margin-top: 8px;
    }

    .modal-header-dark .modal-meta span {
      display: flex;
      align-items: center;
      gap: 4px;
    }

    /* Light body background */
    .modal-body-light {
      padding: 20px 24px;
      background: #f8f9fa;
      max-height: 70vh;
      overflow-y: auto;
    }

    /* Info cards in modal body */
    .modal-info-card {
      background: white;
      border-radius: 10px;
      padding: 16px;
      margin-bottom: 16px;
      box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    }

    .modal-info-card-title {
      font-size: 11px;
      text-transform: uppercase;
      color: #666;
      font-weight: 600;
      letter-spacing: 0.5px;
      margin-bottom: 12px;
    }

    .modal-info-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
    }

    .modal-info-grid.cols-3 {
      grid-template-columns: repeat(3, 1fr);
    }

    .modal-info-item {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .modal-info-item .label {
      font-size: 10px;
      color: #888;
      text-transform: uppercase;
      letter-spacing: 0.3px;
    }

    .modal-info-item .value {
      font-size: 14px;
      color: #333;
      font-weight: 500;
    }

    /* Modal actions/buttons */
    .modal-actions {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      padding: 16px 24px;
      background: white;
      border-top: 1px solid #e0e0e0;
    }

    .modal-actions.centered {
      justify-content: center;
    }

    .modal-btn {
      padding: 10px 20px;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s;
      border: none;
    }

    .modal-btn-primary {
      background: #8B1538;
      color: white;
    }

    .modal-btn-primary:hover {
      background: #a01d42;
    }

    .modal-btn-secondary {
      background: #f3f4f6;
      color: #374151;
      border: 1px solid #d1d5db;
    }

    .modal-btn-secondary:hover {
      background: #e5e7eb;
    }

    /* Status badges for modals */
    .modal-status-badge {
      display: inline-flex;
      align-items: center;
      padding: 6px 12px;
      border-radius: 6px;
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .modal-status-badge.success { background: #22c55e; color: white; }
    .modal-status-badge.warning { background: #f59e0b; color: #1a1a1a; }
    .modal-status-badge.danger { background: #dc2626; color: white; }
    .modal-status-badge.info { background: #3b82f6; color: white; }
    .modal-status-badge.neutral { background: #6b7280; color: white; }

    /* Loading state for redesigned modals */
    .modal-redesign .loading {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 60px 20px;
      color: #666;
    }

    .modal-redesign .loading-spinner {
      display: inline-block;
      width: 32px;
      height: 32px;
      border: 3px solid #e0e0e0;
      border-top-color: #8B1538;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-bottom: 12px;
    }

    .modal-redesign .loading-text {
      font-size: 14px;
      color: #888;
    }

    /* ==================== END UNIFIED MODAL DESIGN SYSTEM ==================== */
