/* CAKRA - Report Module Styles */

/* ==========================================
   REPORT SECTION CONTAINER
   ========================================== */
#tab-report {
  display: none;
  flex-direction: column;
  height: 100%;
  background: var(--bg-base);
  overflow: hidden;
}

#tab-report.active {
  display: flex;
}

/* ==========================================
   REPORT TOOLBAR
   ========================================== */
.report-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.report-toolbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 8px;
}

.report-period-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-period-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.report-period-pill {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
}

.report-period-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.report-period-btn.active {
  background: var(--brand-primary);
  color: #fff;
}

.report-period-btn:hover:not(.active) {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.report-site-select {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 180px;
}

/* Date Range Manual Inputs */
.report-date-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-date-input {
  padding: 5px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
  max-width: 135px;
}

.report-date-input:focus {
  border-color: var(--brand-primary, #3b82f6);
}

.report-date-sep {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Site Checklist Dropdown Popover */
.report-site-checklist-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.report-site-checklist-wrap label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.report-site-dropdown {
  position: relative;
}

.report-site-trigger {
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.report-site-trigger:hover,
.report-site-trigger:focus {
  border-color: var(--brand-primary, #3b82f6);
}

.report-site-trigger-caret {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.report-site-dropdown.open .report-site-trigger-caret {
  transform: rotate(180deg);
}

.report-site-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 1050;
  flex-direction: column;
  overflow: hidden;
  animation: reportMenuFade 0.15s ease;
}

@keyframes reportMenuFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.report-site-dropdown.open .report-site-menu {
  display: flex;
}

.report-site-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-elevated, #0f172a);
  border-bottom: 1px solid var(--border-color);
}

.report-site-menu-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.report-site-quick-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-site-quick {
  background: none;
  border: none;
  color: var(--brand-primary, #38bdf8);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.btn-site-quick:hover {
  text-decoration: underline;
  background: rgba(56, 189, 248, 0.1);
}

.quick-sep {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.report-site-search-wrap {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.report-site-search-input {
  width: 100%;
  padding: 5px 10px;
  font-size: 0.78rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
}

.report-site-search-input:focus {
  border-color: var(--brand-primary, #38bdf8);
}

.report-site-checklist-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}

.report-site-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s ease;
  user-select: none;
}

.report-site-check-item:hover {
  background: var(--bg-elevated);
}

.report-site-check-item input[type="checkbox"] {
  accent-color: var(--brand-primary, #2563eb);
  cursor: pointer;
  width: 15px;
  height: 15px;
}

.report-site-check-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.report-site-check-name {
  font-weight: 600;
  color: var(--text-primary);
}

.report-site-check-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.report-site-menu-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
}

#report-site-count-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-site-apply {
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--brand-primary, #2563eb);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-site-apply:hover {
  background: #1d4ed8;
}

.report-toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-report-refresh {
  padding: 7px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-report-refresh:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-report-pdf {
  padding: 7px 18px;
  background: #dc2626;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-report-pdf:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}

.btn-report-excel {
  padding: 7px 18px;
  background: #16a34a;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-report-excel:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

/* ==========================================
   REPORT PREVIEW AREA
   ========================================== */
.report-preview-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-base);
}

/* Empty state */
.report-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  gap: 12px;
  color: var(--text-muted);
}

.report-empty-state .icon {
  font-size: 4rem;
  opacity: 0.4;
}

.report-empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0;
}

.report-empty-state p {
  font-size: 0.85rem;
  margin: 0;
  text-align: center;
}

/* ==========================================
   DOCUMENT PAPER (A4-like)
   ========================================== */
.report-document {
  background: #ffffff;
  color: #0f172a;
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 56px;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  font-family: 'Inter', 'Segoe UI', sans-serif;
}

[data-theme="dark"] .report-document {
  background: #1e3347;
  color: #F0F0F0;
  border: 1px solid #3d5870;
  box-shadow: 0 4px 24px rgba(15, 28, 40, 0.6);
}

/* ==========================================
   DOCUMENT HEADER
   ========================================== */
.report-doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 3px solid #4A6E8D;
}

.report-org-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-org-logo {
  font-size: 2rem;
  font-weight: 900;
  color: #4A6E8D;
  letter-spacing: -1px;
  line-height: 1;
}

[data-theme="dark"] .report-org-logo {
  color: #A4C8E1;
}

.report-org-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

[data-theme="dark"] .report-org-name {
  color: #A4C8E1;
}

.report-meta-block {
  text-align: right;
}

.report-doc-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

[data-theme="dark"] .report-doc-title {
  color: #f1f5f9;
}

.report-meta-table {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.8;
}

[data-theme="dark"] .report-meta-table {
  color: #94a3b8;
}

.report-meta-table strong {
  color: #334155;
}

[data-theme="dark"] .report-meta-table strong {
  color: #cbd5e1;
}

.report-doc-number {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  background: #1e40af;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ==========================================
   SECTION HEADERS
   ========================================== */
.report-section {
  margin-top: 36px;
}

.report-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #4A6E8D;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="dark"] .report-section-title {
  color: #A4C8E1;
}

.report-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.25;
}

/* ==========================================
   EXECUTIVE SUMMARY KPI CARDS
   ========================================== */
.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}

.report-kpi-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .report-kpi-card {
  background: #24394d;
  border-color: #3d5870;
}

.report-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-accent, #4A6E8D);
  border-radius: 10px 10px 0 0;
}

.report-kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

[data-theme="dark"] .report-kpi-label {
  color: #A4C8E1;
}

.report-kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
}

[data-theme="dark"] .report-kpi-value {
  color: #F0F0F0;
}

.report-kpi-sub {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
}

[data-theme="dark"] .report-kpi-sub {
  color: #7b9bb5;
}

/* ==========================================
   TABLES
   ========================================== */
.report-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

[data-theme="dark"] .report-table-wrap {
  border-color: #3d5870;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.report-table thead tr {
  background: #f1f5f9;
}

[data-theme="dark"] .report-table thead tr {
  background: #1B3A57;
}

.report-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

[data-theme="dark"] .report-table thead th {
  color: #A4C8E1;
  border-bottom-color: #3d5870;
}

.report-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}

[data-theme="dark"] .report-table tbody tr {
  border-bottom-color: #2C3E50;
}

.report-table tbody tr:last-child {
  border-bottom: none;
}

.report-table tbody tr:hover {
  background: #f8fafc;
}

[data-theme="dark"] .report-table tbody tr:hover {
  background: #2C3E50;
}

.report-table tbody td {
  padding: 10px 14px;
  color: #334155;
  vertical-align: middle;
}

[data-theme="dark"] .report-table tbody td {
  color: #F0F0F0;
}

.report-table tbody td strong {
  color: #0f172a;
  font-weight: 600;
}

[data-theme="dark"] .report-table tbody td strong {
  color: #f1f5f9;
}

/* SLA Status Badges */
.sla-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sla-badge.excellent { background: #dcfce7; color: #15803d; }
.sla-badge.good { background: #dbeafe; color: #1d4ed8; }
.sla-badge.warning { background: #fef3c7; color: #b45309; }
.sla-badge.poor { background: #fee2e2; color: #dc2626; }

[data-theme="dark"] .sla-badge.excellent { background: rgba(21, 128, 61, 0.2); color: #4ade80; }
[data-theme="dark"] .sla-badge.good { background: rgba(29, 78, 216, 0.2); color: #60a5fa; }
[data-theme="dark"] .sla-badge.warning { background: rgba(180, 83, 9, 0.2); color: #fbbf24; }
[data-theme="dark"] .sla-badge.poor { background: rgba(220, 38, 38, 0.2); color: #f87171; }

/* Uptime % colored text */
.uptime-excellent { color: #16a34a; font-weight: 700; }
.uptime-good { color: #2563eb; font-weight: 700; }
.uptime-warning { color: #d97706; font-weight: 700; }
.uptime-poor { color: #dc2626; font-weight: 700; }

/* ==========================================
   DOCUMENT FOOTER
   ========================================== */
.report-doc-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: #94a3b8;
}

[data-theme="dark"] .report-doc-footer {
  border-color: #1e3a5f;
}

/* ==========================================
   LOADING STATE
   ========================================== */
.report-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  gap: 16px;
  color: var(--text-muted);
}

.report-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: report-spin 0.8s linear infinite;
}

@keyframes report-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   PRINT STYLES (PDF)
   ========================================== */
@media print {
  body > * {
    display: none !important;
  }

  #tab-report {
    display: block !important;
  }

  .report-toolbar,
  .report-toolbar-actions,
  .btn-report-pdf,
  .btn-report-excel,
  .btn-report-refresh {
    display: none !important;
  }

  .report-preview-area {
    padding: 0;
    overflow: visible;
  }

  .report-document {
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
    padding: 24mm 20mm;
    color: #000 !important;
    background: #fff !important;
    page-break-inside: avoid;
  }

  .report-kpi-card {
    background: #f8f8f8 !important;
    border: 1px solid #ddd !important;
  }

  .report-kpi-value {
    color: #000 !important;
  }

  .report-doc-title,
  .report-org-name {
    color: #000 !important;
  }

  .report-section-title {
    color: #1e40af !important;
  }

  .report-table {
    page-break-inside: auto;
  }

  .report-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .report-table thead {
    display: table-header-group;
  }

  .report-section {
    page-break-inside: avoid;
  }

  @page {
    size: A4;
    margin: 15mm 10mm;
  }
}

/* Responsive untuk layar kecil */
@media (max-width: 768px) {
  .report-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .report-document {
    padding: 24px 20px;
  }

  .report-doc-header {
    flex-direction: column;
    gap: 16px;
  }

  .report-meta-block {
    text-align: left;
  }

  .report-toolbar {
    gap: 8px;
  }
}
