/* =========================================================================
   WEEKLY-THEME.CSS — Tema Gelap / Terang untuk Dashboard Meeting
   ========================================================================= */

:root,
:root[data-wd-theme="dark"] {
  /* DARK THEME - ELEGANT GLASSMORPHISM */
  --wd-bg:            #0B1120;
  --wd-bg-side:       rgba(15, 23, 42, 0.4);
  --wd-card:          rgba(30, 41, 59, 0.4);
  --wd-card-2:        rgba(15, 23, 42, 0.3);
  --wd-border:        rgba(255, 255, 255, 0.06);
  --wd-border-soft:   rgba(255, 255, 255, 0.03);
  --wd-note-border:   rgba(97, 146, 252, 0.3);
  --wd-text: #eef1f5;
  --wd-text-strong:   #f5efef;
  --wd-text-mute:     #94A3B8;
  --wd-text-dim:      #64748B;
  --wd-hover:         rgba(255, 255, 255, 0.06);
  --wd-accent:        #3B82F6;
  --wd-accent-text:   #FFFFFF;
  --wd-link:          #60A5FA;
  --wd-grid:          rgba(255, 255, 255, 0.04);
  --wd-axis:          #475569;
  --wd-shadow:        0 8px 32px rgba(0, 0, 0, 0.3);

  /* Status Colors */
  --wd-oee-ope:       #16a34a; /* Hijau Tua saat tercapai (OPE) */
  --wd-oee-365:       #3B82F6; /* Biru saat tercapai (365) */
  --wd-chart-green:   #16a34a;
  --wd-chart-amber:   #EF4444;
  --wd-chart-red:     #EF4444; 

  /* Gradients & Gauges */
  --wdt-page:         radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.07), transparent 45%),
                      radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.07), transparent 45%),
                      var(--wd-bg);
  --wdt-panel:        linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.005) 100%);
  --wdt-panel-bd:     rgba(255, 255, 255, 0.747);
  --wdt-hero-bar:     linear-gradient(135deg, rgba(30, 58, 138, 0.8) 0%, rgba(59, 130, 246, 0.8) 100%);
  --wdt-gauge-ope:    #16a34a;
  --wdt-gauge-365:    #3B82F6; 
  
  /* Tables - DARK MODE */
  --wdt-th-bg:        #ffeded;
  --wdt-th-text:      #000000;
  --wdt-td-bg: rgb(0 3 13 / 85%); /* Sangat transparan, efek kaca yang ringan */
  --wdt-td-bd: rgba(233, 230, 230, 0.8);
  --wdt-td-text: #f9f9f9; /* Ubah dari #450d0d menjadi Putih */

  /* Warna Status OEE Rincian Produk - DARK MODE */
  --rp-ok-bg: #5DCF00; /* Hijau Terang */
  --rp-ok-text: #01130b;
  --rp-fail-bg: rgb(233, 25, 25);
  --rp-fail-text: #e7d9d9;
}



:root[data-wd-theme="light"] {
  /* LIGHT THEME */
  --wd-bg:            #EFF0F4;
  --wd-bg-side:       #FFFFFF;
  --wd-card:          #FFFFFF;
  --wd-card-2:        #F8F9FB;
  
  --wd-border:        #DCE0E8;
  --wd-border-soft:   #E4E7F0;
  --wd-note-border:   #6192FC;
  
  --wd-text:          #000000; 
  --wd-text-strong:   #091E52;
  --wd-text-mute:     #2E4A7D;
  --wd-text-dim:      #6C7D9E;
  
  --wd-hover:         #EBF1FF;
  --wd-accent:        #6192FC;
  --wd-accent-text:   #FFFFFF;
  --wd-link:          #11358B;
  
  --wd-grid:          #DCE0E8;
  --wd-axis:          #6C7D9E;
  
  --wd-shadow:        0 8px 24px rgba(17, 53, 139, 0.08);

  --wd-oee-ope:       #16a34a; 
  --wd-oee-365:       #6192FC; 
  --wd-chart-green:   #16a34a;
  --wd-chart-amber:   #DC2626; 
  --wd-chart-red:     #DC2626; 

  --wdt-page:         var(--wd-bg);
  --wdt-panel:        #FFFFFF;
  --wdt-panel-bd:     #000000;
  --wdt-hero-bar:     linear-gradient(135deg, #11358B 0%, #6192FC 100%);
  --wdt-gauge-ope:    #16a34a; 
  --wdt-gauge-365:    #6192FC; 
  
  /* Tables - LIGHT MODE */
  --wdt-th-bg:        #0F1E36; 
  --wdt-th-text:      #FFFFFF; 
  --wdt-td-bg:        #FFFFFF; 
  --wdt-td-bd:        #010608;
  --wdt-td-text:      #000000; /* Tambahkan ini: Teks Hitam untuk mode terang */

  /* Warna Status OEE Rincian Produk - LIGHT MODE */
  --rp-ok-bg: #d1fae5;
  --rp-ok-text: #065f46;
  --rp-fail-bg: #fee2e2;
  --rp-fail-text: #991b1b;


}



/* Rangka CSS Weekly Theme */
:root[data-wd-theme="pink"] { display: none; }

.weekly-layout { background: var(--wdt-page, var(--wd-bg)); }
.weekly-layout .weekly-main { background: transparent; }
.weekly-layout .weekly-sidebar { 
  background: var(--wdt-side, var(--wd-bg-side)); 
  border-right: 1px solid var(--wd-border); 
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.weekly-layout .weekly-hero::before { background: var(--wdt-hero-bar); }

.weekly-layout .weekly-nav-item.is-active { background: var(--wd-hover); color: var(--wd-link); box-shadow: inset 3px 0 0 var(--wd-link); }

.weekly-layout .oee-panel, .weekly-layout .oee-trend-card, .weekly-layout .oee-bar-card, .weekly-layout .weekly-card, .weekly-layout .wd-tot-card, .weekly-layout .shutdown-card {
  background: var(--wdt-panel); 
  border: 1px solid var(--wdt-panel-bd); 
  box-shadow: var(--wd-shadow); 
  border-radius: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.weekly-layout .oee-panel-head, .weekly-layout .oee-gauge-title { color: var(--wd-text); }
.weekly-layout .oee-actual { color: var(--wd-text-strong); }
.weekly-layout .oee-apq-item { background: var(--wd-card-2); border-color: var(--wd-border); }
/* --- TAMBAHKAN INI UNTUK WARNA HIJAU/MERAH --- */
.weekly-layout .oee-apq-item.over {
  background-color: #dcfce7 !important; /* Latar Hijau */
  border-color: #030303 !important;    /* Garis Hijau */
}

.weekly-layout .oee-apq-item.under {
  background-color: #fee2e2 !important; /* Latar Merah */
  border-color: #030303 !important;    /* Garis Merah */
}

.weekly-layout .oee-apq-item.over .oee-apq-val {
  color: #166534 !important; /* Teks Hijau Gelap */
}

.weekly-layout .oee-apq-item.under .oee-apq-val {
  color: #991b1b !important; /* Teks Merah Gelap */
}
.weekly-layout .oee-apq-val { color: var(--wd-text-strong); }

.weekly-layout .oee-track { stroke: #957d71; }
.weekly-layout .oee-fill-blue { stroke: var(--wdt-gauge-ope); }
.weekly-layout .oee-fill-green { stroke: var(--wdt-gauge-365); }

/* =====================================================================
   OVERRIDE: Paksa Warna Merah Jika JS Menyuntikkan Warna Kuning/Oranye
   ===================================================================== */
:root:not([data-wd-theme="light"]) .weekly-layout .oee-fill[style*="stroke: #FBBF24"],
:root:not([data-wd-theme="light"]) .weekly-layout .oee-fill[style*="stroke: #fbbf24"],
:root:not([data-wd-theme="light"]) .weekly-layout .oee-fill[style*="stroke: rgb(251, 191, 36)"],
:root:not([data-wd-theme="light"]) .weekly-layout .oee-fill[style*="stroke: orange"] {
  stroke: #EF4444 !important;
}

:root[data-wd-theme="light"] .weekly-layout .oee-fill[style*="stroke: #FBBF24"],
:root[data-wd-theme="light"] .weekly-layout .oee-fill[style*="stroke: #fbbf24"],
:root[data-wd-theme="light"] .weekly-layout .oee-fill[style*="stroke: rgb(251, 191, 36)"],
:root[data-wd-theme="light"] .weekly-layout .oee-fill[style*="stroke: orange"] {
  stroke: #DC2626 !important;
}

/* Status Shutdown & Unplanned */
/* Status Shutdown & Unplanned */
/* Mode Gelap — Kartu Output Defect */
:root[data-wd-theme="dark"] .wd-tot-card[data-metric="defect"],
:root:not([data-wd-theme="light"]) .wd-tot-card[data-metric="defect"] {
  text-align: center !important;
  background-color: rgba(43, 3, 3, 0.466) !important; /* latar kartu */
  border-color: #ef4444 !important;                  /* garis tepi kartu */
}

:root[data-wd-theme="dark"] .wd-tot-card[data-metric="defect"] .wd-tot-label,
:root[data-wd-theme="dark"] .wd-tot-card[data-metric="defect"] .wd-tot-unit,
:root:not([data-wd-theme="light"]) .wd-tot-card[data-metric="defect"] .wd-tot-label,
:root:not([data-wd-theme="light"]) .wd-tot-card[data-metric="defect"] .wd-tot-unit {
  color: #f1e8e8 !important; /* warna teks "Output Defect" & "unit" */
}

:root[data-wd-theme="dark"] .wd-tot-card[data-metric="defect"] .wd-tot-val,
:root:not([data-wd-theme="light"]) .wd-tot-card[data-metric="defect"] .wd-tot-val {
  color: #dac6c6 !important; /* warna angka utama */
}

/* Mode Terang — Kartu Output Defect */
:root[data-wd-theme="light"] .wd-tot-card[data-metric="defect"] {
  background-color: #fef2f2 !important;
  border-color: #fecaca !important;
}

:root[data-wd-theme="light"] .wd-tot-card[data-metric="defect"] .wd-tot-label,
:root[data-wd-theme="light"] .wd-tot-card[data-metric="defect"] .wd-tot-unit {
  color: #991b1b !important;
}

:root[data-wd-theme="light"] .wd-tot-card[data-metric="defect"] .wd-tot-val {
  color: #b91c1c !important;
}
:root:not([data-wd-theme="light"]) .wd-tot-card:has(#oeeTotD) .wd-tot-val { color: #FF6B6B !important; }

/* Filter UI */
.weekly-layout .oee-filter-extended input[type="date"], .weekly-layout .oee-filter-extended select {
  background: var(--wd-card); border-color: var(--wd-border); color: var(--wd-text);
}
.weekly-layout .oee-filter-extended .btn-primary { background: var(--wd-link); color: #FFF; border: none; }
.weekly-layout .oee-filter-extended .btn-ghost { background: transparent; border: 1px solid var(--wd-border); color: var(--wd-text); }

/* Tabel UI */
.weekly-layout .rp-table thead th, 
.weekly-layout .issue-table thead th, 
.weekly-layout .shutdown-table thead th, 
.weekly-layout .speed-table thead th {
  background: var(--wdt-th-bg) !important; 
  color: var(--wdt-th-text) !important; 
  border-bottom: 1px solid var(--wdt-panel-bd) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.weekly-layout .rp-table thead th *, 
.weekly-layout .issue-table thead th *, 
.weekly-layout .shutdown-table thead th *, 
.weekly-layout .speed-table thead th * {
  color: var(--wdt-th-text) !important;
}

.weekly-layout .rp-table tbody td, 
.weekly-layout .issue-table tbody td, 
.weekly-layout .shutdown-table tbody td, 
.weekly-layout .speed-table tbody td {
  background: var(--wdt-td-bg) !important;  
  border-bottom: 1px solid #0f99bb !important;
  color: var(--wdt-td-text) !important;
}

/* Selector Tema */
.wd-theme-switch {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px;
  border: 1px solid var(--wdt-panel-bd); background: var(--wdt-panel); box-shadow: var(--wd-shadow);
}
.wd-tbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 0; border-radius: 999px;
  background: transparent; color: var(--wd-text-mute); font: 600 11px var(--font-sans); cursor: pointer;
}
.wd-tbtn:hover { background: var(--wd-hover); color: var(--wd-text-strong); }
.wd-tbtn[aria-checked="true"] { background: var(--wd-hover); color: var(--wd-text-strong); box-shadow: inset 0 0 0 1px var(--wdt-panel-bd); }
.wd-tbtn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wd-tbtn[data-wd-mode="pink"] { display: none; }

/* Kartu polos */
:root:not([data-wd-theme="light"]) .weekly-layout .wd-tot-card:not(.wd-tot-plane):not(.wd-tot-unplane):not(.wd-tot-ops):not(:has(#oeeTotD, #mchTotD, #oeeTotDefect, #mchTotDefect, #oeeTotE, #mchTotE, #oeeTotGood, #mchTotGood)) .wd-tot-val {
  color: #ffffff !important;
}
:root:not([data-wd-theme="light"]) .weekly-layout .wd-tot-card:not(.wd-tot-plane):not(.wd-tot-unplane):not(.wd-tot-ops):not(:has(#oeeTotD, #mchTotD, #oeeTotDefect, #mchTotDefect, #oeeTotE, #mchTotE, #oeeTotGood, #mchTotGood)) .wd-tot-label,
:root:not([data-wd-theme="light"]) .weekly-layout .wd-tot-card:not(.wd-tot-plane):not(.wd-tot-unplane):not(.wd-tot-ops):not(:has(#oeeTotD, #mchTotD, #oeeTotDefect, #mchTotDefect, #oeeTotE, #mchTotE, #oeeTotGood, #mchTotGood)) .wd-tot-unit {
  color: #ffffff !important;
}

/* Garis pembatas emas pada kotak WEEKLY OEE OPE, SPEED STANDAR, WEEKLY OEE 365. */
:root:not([data-wd-theme="light"]) .weekly-layout .oee-panel {
  border: 1px solid #d4af37 !important;
}

/* Taruh di file CSS */
.issue-edit {
  field-sizing: content !important; 
  min-height: 1.5em;
  overflow-y: hidden;
}

/* Menambahkan garis vertikal antar kolom tabel */
.weekly-layout .issue-table th,
.weekly-layout .issue-table td {
  border-right: 1px solid var(--wdt-td-bd) !important;
}

/* Menghapus garis di ujung paling kanan agar tabel terlihat rapi */
.weekly-layout .issue-table th:last-child,
.weekly-layout .issue-table td:last-child {
  border-right: none !important;
}

/* =======================================================
   FIX MUTLAK: Sinkronisasi Warna Tabel PICA & Issue
   ======================================================= */

/* ---------------------------------------------------
1. MODE GELAP (Menggunakan data-wd-theme="dark")
   --------------------------------------------------- */
:root[data-wd-theme="dark"] .pica-card .pica-table tbody tr,
:root[data-wd-theme="dark"] .pica-card .pica-table tbody td {
  background-color: #0b1a2a !important; /* Paksa background jadi GELAP */
  color: #e2e8f0 !important; /* Paksa teks jadi PUTIH TERANG */
  border-bottom: 1px solid #d1d8e4 !important;
  border-right: 1px solid #d1d8e4 !important;
}

/* Link (Produk seperti VTRA1) di Mode Gelap */
:root[data-wd-theme="dark"] .pica-card .pica-table .pica-link {
  color: #60a5fa !important; /* Biru cerah */
}

/* ---------------------------------------------------
   2. MODE TERANG (Menggunakan data-wd-theme="light")
   --------------------------------------------------- */
:root[data-wd-theme="light"] .pica-card .pica-table tbody tr,
:root[data-wd-theme="light"] .pica-card .pica-table tbody td {
  background-color: #ffffff !important; /* Background PUTIH */
  color: #0f172a !important; /* Teks HITAM GELAP */
  border-bottom: 1px solid #121213 !important;
  border-right: 1px solid #121213 !important;
}

/* Link (Produk seperti VTRA1) di Mode Terang */
:root[data-wd-theme="light"] .pica-card .pica-table .pica-link {
  color: #0284c7 !important; /* Biru gelap */
}

/* ---------------------------------------------------
   3. FIX UNTUK TABEL ISSUE (Tabel Bawah)
   --------------------------------------------------- */
/* Mode Gelap */
:root[data-wd-theme="dark"] .issue-table tbody td,
:root[data-wd-theme="dark"] .issue-table td.mono {
  color: #e2e8f0 !important;
}
:root[data-wd-theme="dark"] .issue-table tbody tr:hover td,
:root[data-wd-theme="dark"] .issue-table tbody tr:hover td.mono,
:root[data-wd-theme="dark"] .issue-table tbody tr:hover td * {
  background-color: #0e53ad !important;
  color: #eee8e8 !important;
}

/* Mode Terang */
:root[data-wd-theme="light"] .issue-table tbody td,
:root[data-wd-theme="light"] .issue-table td.mono {
  color: #0f172a !important;
}
:root[data-wd-theme="light"] .issue-table tbody tr:hover td,
:root[data-wd-theme="light"] .issue-table tbody tr:hover td.mono,
:root[data-wd-theme="light"] .issue-table tbody tr:hover td * {
  background-color: #e48eb6 !important;
  color: #0e0f0f !important;
}

/* Warna angka nilai, No.Batch, & nama produk grafik #mchBatchSvg */
:root:not([data-wd-theme="light"]) #mchBatchSvg > text {
  fill: #eef1f5 !important; /* Warna terang saat Mode Gelap */
}

:root[data-wd-theme="light"] #mchBatchSvg > text {
  fill: #0f172a !important; /* Warna gelap saat Mode Terang */
}

/* Border kotak grafik No.Batch saat Mode Gelap */
:root:not([data-wd-theme="light"]) .weekly-layout .mch-batch-chart {
  border: 1.5px solid #ffffff !important;
  border-radius: 10px;
}

/* Warna angka persentase grafik OEE Production saat Mode Terang */
:root[data-wd-theme="light"] #chartOeeOpe text[fill="#93c5fd"] {
  fill: #1d4ed8 !important; /* Biru tua untuk Capaian OEE OPE */
}

:root[data-wd-theme="light"] #chartOee365 text[fill="#86efac"],
:root[data-wd-theme="light"] #oeeBarFfs text[fill="#86efac"] {
  fill: #15803d !important; /* Hijau tua untuk OEE 365 & FFS OPE */
}

:root[data-wd-theme="light"] #oeeBarFfs text[fill="#fcd34d"] {
  fill: #b45309 !important; /* Cokelat/oranye tua untuk FFS OEE 365 */
}

:root[data-wd-theme="light"] #oeeBarOw text[fill="#fda4af"] {
  fill: #be123c !important; /* Merah tua untuk Overwrapping OPE */
}

:root[data-wd-theme="light"] #oeeBarOw text[fill="#a5f3fc"] {
  fill: #0e7490 !important; /* Biru cyan tua untuk Overwrapping OEE 365 */
}

/* Mode Terang (Light Mode) -> Teks angka & label batang menjadi HITAM */
:root[data-wd-theme="light"] .oee-bar-card #oeeBarFfs > g > text,
:root[data-wd-theme="light"] .oee-bar-card #oeeBarOw > g > text {
  fill: #000000 !important;
}

/* Mode Gelap (Dark Mode) -> Teks angka & label batang menjadi PUTIH */
:root[data-wd-theme="dark"] .oee-bar-card #oeeBarFfs > g > text,
:root[data-wd-theme="dark"] .oee-bar-card #oeeBarOw > g > text {
  fill: #ffffff !important;
}

/* Mode Terang (Light Mode) -> Teks grafik tren OEE OPE & OEE 365 menjadi HITAM */
:root[data-wd-theme="light"] #weeklyPageOee #chartOeeOpe > text,
:root[data-wd-theme="light"] #weeklyPageOee #chartOee365 > text {
  fill: #000000 !important;
}

/* Mode Gelap (Dark Mode) -> Teks grafik tren OEE OPE & OEE 365 menjadi PUTIH */
:root[data-wd-theme="dark"] #weeklyPageOee #chartOeeOpe > text,
:root[data-wd-theme="dark"] #weeklyPageOee #chartOee365 > text {
  fill: #ffffff !important;
}


/* Rata tengah semua tulisan di kartu ringkasan (.wd-tot-card) */
.weekly-layout .wd-totals .wd-tot-card,
.weekly-layout .wd-totals .wd-tot-label,
.weekly-layout .wd-totals .wd-tot-val,
.weekly-layout .wd-totals .wd-tot-unit {
  text-align: center !important;
}

