/* ==========================================
   RMS + AI DIGITAL MODULE - POLYCC / JPPKK
   Design System & Print Layout
   ========================================== */

:root {
  /* Color Palette - Clean Professional Light Theme */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  
  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --glow-accent: 0 4px 14px rgba(79, 70, 229, 0.25);
  
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --purple: #6b21a8;
  --purple-bg: #f3e8ff;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.7);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  
  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  
  --success: #4ade80;
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --purple: #c084fc;
  --purple-bg: rgba(168, 85, 247, 0.15);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.15);
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* Layout Grid */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 120;
  transition: transform var(--transition-normal);
}

.brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-sm);
}

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-text span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-list {
  list-style: none;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background: var(--accent-gradient);
  color: #ffffff !important;
  box-shadow: var(--glow-accent);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.user-info p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Wrapper */
.main-wrapper {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-header {
  min-height: 68px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* View Panel Tab Switching */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.nav-shortcut-card {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-shortcut-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Cards & Glassmorphism */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

/* Controls & Inputs */
.select-control, .input-control, .textarea-control {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.select-control:focus, .input-control:focus, .textarea-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.82rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--glow-accent);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.quick-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.icon-btn, .theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.icon-btn:hover, .theme-toggle-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(21, 128, 61, 0.2); }
.badge-danger, .badge-notyet { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-warning, .badge-inprogress { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-done { background: rgba(59, 130, 246, 0.15); color: #2563eb; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-purple, .badge-postponed { background: rgba(168, 85, 247, 0.15); color: var(--purple); border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-amber, .badge-other { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(3, 105, 161, 0.2); }

/* Visual Monthly Calendar Grid */
.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.calendar-day-head {
  text-align: center;
  font-weight: 800;
  padding: 10px 4px;
  background: var(--bg-secondary);
  color: var(--accent-primary);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
}

.calendar-day-cell {
  min-height: 105px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.calendar-day-cell:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.calendar-day-cell.other-month {
  background: #f8fafc;
  opacity: 0.35;
  border-style: dashed;
}

.calendar-day-cell.today-cell {
  border: 2px solid var(--accent-primary);
  background: rgba(99, 102, 241, 0.03);
}

.calendar-day-number {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 3px;
  margin-bottom: 2px;
}

.calendar-event-badge {
  font-size: 0.68rem;
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1.25;
  font-weight: 600;
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Calendar Task Icon Chips (Compact & Interactive) */
.cal-icons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 3px;
}

.cal-task-icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: 7px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.cal-task-icon-chip:hover {
  transform: scale(1.22) translateY(-2px);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.cal-task-icon-chip.cat-koperasi {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}
.cal-task-icon-chip.cat-pelan-strategik {
  background: #ffe4e6;
  color: #e11d48;
  border-color: #fecdd3;
}
.cal-task-icon-chip.cat-pdp-sop30343 {
  background: #e0e7ff;
  color: #4338ca;
  border-color: #c7d2fe;
}
.cal-task-icon-chip.cat-pdp-sop10253 {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.cal-task-icon-chip.cat-unit-sop {
  background: #f3e8ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}
.cal-task-icon-chip.cat-lain-lain {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.cal-action-subdot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid #fff;
}
.cal-action-subdot.dot-done { background: #2563eb; }
.cal-action-subdot.dot-inprogress { background: #16a34a; }
.cal-action-subdot.dot-notyet { background: #dc2626; }
.cal-action-subdot.dot-postponed { background: #9333ea; }
.cal-action-subdot.dot-other { background: #d97706; }

.cal-event-mini-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 36px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* RMS 9-Column Table Formatting */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.rms-main-table {
  width: 100%;
  min-width: 1350px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.rms-main-table th {
  background: var(--bg-glass);
  padding: 8px 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Prevent long badge labels (e.g. "MINGGU ORIENTASI") from spilling into neighbouring cells */
.rms-main-table .badge {
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}

.rms-main-table th:last-child {
  border-right: none;
}

.rms-main-table td {
  padding: 8px 6px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  font-size: 0.78rem;
  vertical-align: top;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.rms-main-table td:last-child {
  border-right: none;
}

.rms-main-table tr:hover td {
  background: rgba(79, 70, 229, 0.03);
}

/* Cell Specific Wrapping */
.topic-cell {
  white-space: pre-line;
  font-weight: 500;
  word-break: break-word;
}

/* Structured Sub-Box Cards inside Reflection Column */
.sub-reflection-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.sub-box-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.sub-box-card.notes-box { border-left: 3px solid var(--accent-primary); }
.sub-box-card.reflection-box { border-left: 3px solid var(--purple); }
.sub-box-card.analysis-box { border-left: 3px solid var(--info); }
.sub-box-card.cqi-last-box { border-left: 3px solid var(--warning); background: rgba(245, 158, 11, 0.04); }
.sub-box-card.cqi-this-box { border-left: 3px solid var(--success); background: rgba(34, 197, 94, 0.04); }

.sub-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* AI Recommendation Sections inside Modal */
.ai-section-box {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.ai-section-box h4 {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-primary);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-section-box p {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.4;
  white-space: pre-line;
}

.print-signature-block {
  display: none;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .mobile-nav-toggle {
    display: block;
  }
}

/* Print CSS Styling - Matches Official POLYCC / JPPKK Document Format */
@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 9pt;
  }

  .sidebar, .top-header, .filter-bar, .modal-overlay, button, .mobile-nav-toggle, .btn {
    display: none !important;
  }

  .main-wrapper {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  .glass-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }

  .course-info-header-card {
    border: 1.5px solid #000 !important;
    padding: 10px !important;
    margin-bottom: 10px !important;
  }

  .rms-main-table {
    border: 1.5px solid #000 !important;
    border-collapse: collapse !important;
    width: 100% !important;
  }

  .rms-main-table th {
    background: #e2e8f0 !important;
    color: #000 !important;
    border: 1px solid #000 !important;
    padding: 5px !important;
    font-size: 8.5pt !important;
  }

  .rms-main-table td {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #000 !important;
    padding: 5px !important;
    font-size: 8pt !important;
  }

  .rms-main-table td:last-child, .rms-main-table th:last-child {
    display: none !important;
  }

  .sub-box-card {
    border: 1px solid #ccc !important;
    background: #fff !important;
    margin-bottom: 4px !important;
    padding: 4px 6px !important;
  }

  .print-signature-block {
    display: block !important;
  }
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}
