/* =============================================================================
   MSP Module Styles
   ============================================================================= */

/* Sub-tab navigation */
.msp-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color, #334155);
  margin-bottom: 16px;
  overflow-x: auto;
}

.msp-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #94a3b8);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.2s;
}

.msp-tab:hover { background: rgba(255,255,255,0.05); color: #fff; }
.msp-tab.active { background: var(--primary, #3b82f6); color: #fff; }

/* Sections */
.msp-section { display: none; }
.msp-section.active { display: block; }

/* Stats row */
.msp-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .msp-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Utilization bars */
.utilization-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.utilization-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.utilization-client { font-weight: 600; color: #fff; }
.utilization-contract { color: var(--text-secondary, #94a3b8); font-size: 13px; }

.utilization-bar-container {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}

.utilization-bar-container.small { height: 6px; margin-bottom: 4px; }
.utilization-bar-container.large { height: 12px; margin-bottom: 8px; }

.utilization-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.utilization-normal { background: #22c55e; }
.utilization-warning { background: #f59e0b; }
.utilization-critical { background: #ef4444; }
.utilization-overage { background: #ef4444; animation: pulse-bar 1s infinite; }

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.utilization-details {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
}

.utilization-percent { font-weight: 600; }
.utilization-percent.normal { color: #22c55e; }
.utilization-percent.warning { color: #f59e0b; }
.utilization-percent.critical { color: #ef4444; }
.utilization-percent.overage { color: #ef4444; }

/* Period stats */
.period-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-secondary, #94a3b8);
}

/* Contract cards */
.contract-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.contract-card:hover { border-color: var(--primary, #3b82f6); }

.contract-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.contract-name { margin: 0; font-size: 15px; color: #fff; }
.contract-client { font-size: 13px; color: var(--text-secondary, #94a3b8); }

.contract-card-details {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

.contract-rate, .contract-hours, .contract-number {
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
}

.contract-utilization-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 6px;
}

.contract-utilization-mini .utilization-bar-container { flex: 1; }

.contract-card-footer {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}

.ticket-count { color: #f59e0b; }

/* Ticket cards */
.ticket-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.ticket-card:hover { border-color: var(--primary, #3b82f6); }
.ticket-card.sla-breached { border-left: 3px solid #ef4444; }

.ticket-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.ticket-number { font-weight: 600; font-size: 13px; color: var(--primary, #3b82f6); }
.ticket-badges { display: flex; gap: 4px; }
.ticket-subject { font-size: 14px; color: #fff; margin-bottom: 6px; }

.ticket-card-footer {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}

.ticket-client { color: var(--text-secondary, #94a3b8); }

/* MSP ticket row (overview) */
.msp-ticket-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color, #334155);
  cursor: pointer;
  font-size: 13px;
}

.msp-ticket-row:hover { background: rgba(255,255,255,0.03); }
.msp-ticket-row .ticket-subject { flex: 1; color: #fff; }

/* Invoice cards */
.invoice-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.invoice-card:hover { border-color: var(--primary, #3b82f6); }

.invoice-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.invoice-number { font-weight: 600; color: var(--primary, #3b82f6); }

.invoice-card-details {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.invoice-client { color: var(--text-secondary, #94a3b8); font-size: 13px; }
.invoice-amount { font-weight: 600; color: #fff; font-size: 16px; }

.invoice-card-footer {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}

/* Invoice detail table */
.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}

.invoice-items-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border-color, #334155);
  color: var(--text-secondary, #94a3b8);
  font-weight: 500;
}

.invoice-items-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.invoice-items-table tfoot td {
  padding: 6px 8px;
  border: none;
}

.invoice-items-table .total-row td { font-size: 15px; padding-top: 8px; border-top: 1px solid var(--border-color, #334155); }
.invoice-items-table .balance-row td { color: #f59e0b; }

/* Client cards */
.client-card {
  background: var(--card-bg, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 6px;
}

.client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.client-card-header h4 { margin: 0; color: #fff; font-size: 15px; }

.client-card-details {
  display: flex;
  gap: 8px;
  font-size: 13px;
}

/* Badge variants for MSP */
.badge.type-msp { background: #3b82f6; color: #fff; }
.badge.type-project { background: #8b5cf6; color: #fff; }
.badge.type-hourly { background: #f59e0b; color: #000; }
.badge.type-retainer { background: #06b6d4; color: #fff; }

.badge.priority-critical { background: #ef4444; color: #fff; }
.badge.priority-high { background: #f97316; color: #fff; }
.badge.priority-medium { background: #3b82f6; color: #fff; }
.badge.priority-low { background: #6b7280; color: #fff; }

.badge.status-draft { background: #6b7280; color: #fff; }
.badge.status-pending { background: #f59e0b; color: #000; }
.badge.status-active { background: #22c55e; color: #fff; }
.badge.status-paused { background: #f59e0b; color: #000; }
.badge.status-cancelled { background: #ef4444; color: #fff; }
.badge.status-completed { background: #22c55e; color: #fff; }
.badge.status-expired { background: #6b7280; color: #fff; }

.badge.status-open { background: #3b82f6; color: #fff; }
.badge.status-assigned { background: #8b5cf6; color: #fff; }
.badge.status-in_progress { background: #f59e0b; color: #000; }
.badge.status-waiting_on_client { background: #06b6d4; color: #fff; }
.badge.status-waiting_on_vendor { background: #06b6d4; color: #fff; }
.badge.status-escalated { background: #ef4444; color: #fff; }
.badge.status-resolved { background: #22c55e; color: #fff; }
.badge.status-closed { background: #6b7280; color: #fff; }

.badge.status-sent { background: #3b82f6; color: #fff; }
.badge.status-viewed { background: #8b5cf6; color: #fff; }
.badge.status-paid { background: #22c55e; color: #fff; }
.badge.status-partial { background: #f59e0b; color: #000; }
.badge.status-overdue { background: #ef4444; color: #fff; }
.badge.status-void { background: #6b7280; color: #fff; }
.badge.status-billed { background: #8b5cf6; color: #fff; }

.badge.category-badge { background: rgba(255,255,255,0.1); color: var(--text-secondary, #94a3b8); }

/* Detail view */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 480px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-item label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  margin-bottom: 2px;
}

.detail-item span { font-size: 14px; color: #fff; }

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-group.full-width { grid-column: span 2; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary, #94a3b8); margin-bottom: 4px; }

@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } .form-group.full-width { grid-column: span 1; } }

/* Comments */
.comments-list { max-height: 300px; overflow-y: auto; margin-bottom: 12px; }

.comment {
  padding: 10px;
  border-left: 3px solid var(--primary, #3b82f6);
  margin-bottom: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 0 6px 6px 0;
}

.comment-internal { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.05); }

.comment-header {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 4px;
}

.comment-header strong { color: #fff; }
.comment-body { font-size: 14px; color: #e2e8f0; }
.comment-time { color: var(--primary, #3b82f6); font-weight: 500; }

.add-comment { margin-top: 12px; }
.comment-actions { display: flex; gap: 8px; margin-top: 6px; align-items: center; }

/* Services & periods lists */
.services-list, .periods-list { margin-bottom: 12px; }

.service-item, .period-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}

/* MSP filter bar */
.msp-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Ticket stats bar */
.msp-stat-bar {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary, #94a3b8);
  flex-wrap: wrap;
}

/* Text color helpers */
.text-success { color: #22c55e; }
.text-warning { color: #f59e0b; }
.text-danger { color: #ef4444; }
.text-critical { color: #ef4444; }

/* Section header with button */
.msp-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.msp-section .section-header h3 { margin: 0; }
