:root {
  --primary: #0F172A;
  --accent: #2563EB;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text-main: #0F172A;
  --text-sub: #64748B;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.nav-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
}

.nav-item:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.nav-item.active {
  background: #EFF6FF;
  color: var(--accent);
  font-weight: 600;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
}

.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible !important; /* PENTING: Agar tooltip tidak terpotong horizontal */
  padding: 32px;
}

.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   COMPONENTS (Card, Button)
   ========================================= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  overflow: visible !important; /* PENTING: Agar tooltip tidak terpotong */
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: #1D4ED8;
}

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

.btn-edit {
  background: var(--warning);
  color: white;
  margin-right: 6px;
}

.btn-edit:hover {
  background: #D97706;
}

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

.btn-delete:hover {
  background: #DC2626;
}

.action-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

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

.kpi-card {
  padding: 20px;
}

.kpi-label {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.kpi-bar {
  height: 6px;
  background: #F1F5F9;
  border-radius: 3px;
  overflow: hidden;
}

.kpi-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* =========================================
   TABLES
   ========================================= */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 12px 16px;
  background: #F8FAFC;
  color: var(--text-sub);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: #FAFAFA;
}

.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

/* =========================================
   GANTT CHART
   ========================================= */
.gantt-container {
  overflow-x: auto;
}

.gantt-chart {
  display: grid;
  grid-template-columns: 150px 1fr;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 600px;
}

.gantt-header {
  background: #F8FAFC;
  padding: 10px;
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.gantt-timeline {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  border-left: 1px solid var(--border);
}

.gantt-day {
  border-right: 1px solid #F1F5F9;
  font-size: 10px;
  text-align: center;
  padding: 5px 0;
  color: var(--text-sub);
}

.gantt-row-label {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  background: white;
}

.gantt-row-bar {
  position: relative;
  height: 40px;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: #FAFAFA;
}

.gantt-bar {
  position: absolute;
  top: 10px;
  height: 20px;
  background: var(--accent);
  border-radius: 4px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: white;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

/* Gantt: HARI H Marker */
.gantt-event-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: repeating-linear-gradient(to bottom, #EF4444 0, #EF4444 6px, transparent 6px, transparent 12px);
  z-index: 10;
  pointer-events: none;
}

.gantt-event-label {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: #EF4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* =========================================
   CALENDAR (Satu blok terintegrasi)
   ========================================= */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: visible !important; /* PENTING: Agar tooltip tidak terpotong */
}

.cal-header {
  background: #F8FAFC;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.cal-day {
  background: white;
  padding: 8px;
  min-height: 80px;
  font-size: 12px;
  position: relative;
  overflow: visible !important; 
}

.cal-day:hover {
    z-index: 50;
}

.cal-day-num {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-main);
}

/* Hari H Highlight */
.cal-day.event-day {
  background: #FEF2F2 !important;
  border: 2px solid #EF4444 !important;
}

.cal-day.event-day .cal-day-num {
  color: #EF4444;
  font-weight: 800;
}

.cal-day.event-day::after {
  content: '🚩 HARI H';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 9px;
  font-weight: 700;
  color: #EF4444;
  background: #FEE2E2;
  padding: 1px 4px;
  border-radius: 3px;
}

/* Hari Ini Highlight (Kuning) */
.cal-day.today-highlight {
    background: #FEF3C7 !important;
    border: 2px solid #F59E0B !important;
}

.cal-day.today-highlight .cal-day-num {
    color: #92400E;
    font-weight: 800;
}

.cal-day.today-highlight::after {
    content: ' HARI INI';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    font-weight: 700;
    color: #92400E;
    background: #FDE68A;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Calendar Events */
.cal-event {
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  overflow: visible !important;
  z-index: 10;
  background: #EFF6FF;
  color: var(--accent);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 10px;
  margin-bottom: 2px;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-left: 2px solid var(--accent);
}

.cal-event:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  z-index: 50 !important;
}

/* Tooltip/Overlay */
.cal-event-overlay {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0F172A;
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  width: 220px;
  z-index: 9999 !important;
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
  line-height: 1.5;
}

/* Tooltip untuk baris pertama (muncul di BAWAH dengan jarak aman) */
.cal-event-overlay.overlay-below {
  bottom: auto !important;
  top: calc(100% + 12px) !important; /* Jarak lebih jauh dari task */
}

/* Arrow untuk tooltip di atas (default) */
.cal-event-overlay::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #0F172A transparent transparent transparent;
}

/* Arrow untuk tooltip di bawah (baris pertama) */
.cal-event-overlay.overlay-below::after {
  top: auto !important;
  bottom: 100% !important;
  border-color: transparent transparent #0F172A transparent !important;
}

.cal-event:hover .cal-event-overlay {
  visibility: visible !important;
  opacity: 1 !important;
}

.overlay-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #334155;
}

.overlay-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.overlay-label {
  color: #94A3B8;
}

/* =========================================
   MODAL
   ========================================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: white;
  padding: 24px;
  border-radius: 8px;
  width: 400px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

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

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

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

#modal-save:disabled {
  background: #94A3B8 !important;
  cursor: not-allowed;
  opacity: 0.7;
}

#modal-save:disabled:hover {
  background: #94A3B8 !important;
}

/* =========================================
   LOADER
   ========================================= */
.loader {
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

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

/* =========================================
   ERROR & INFO BOX
   ========================================= */
.error-message {
  background: #FEE2E2;
  color: #991B1B;
  padding: 12px;
  border-radius: 6px;
  margin: 16px 0;
  font-size: 14px;
  display: none;
}

.info-box {
  background: #EFF6FF;
  border-left: 4px solid var(--accent);
  padding: 16px;
  border-radius: 0 4px 4px 0;
  margin-bottom: 24px;
  font-size: 14px;
}

.info-box h4 {
  margin-top: 0;
  color: var(--primary);
}

.info-box ul {
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 8px;
}

/* =========================================
   CONFIG SECTION
   ========================================= */
.config-form {
  max-width: 500px;
}

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

.config-form label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.config-form input {
  padding: 10px 12px;
  font-size: 14px;
}

.btn-save-config {
  margin-top: 10px;
}

.btn-save-config:disabled {
  background: #94A3B8;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-save-config:disabled:hover {
  background: #94A3B8;
}

.config-success {
  background: #D1FAE5;
  color: #065F46;
  padding: 12px;
  border-radius: 6px;
  margin-top: 16px;
  display: none;
}

.config-success.show {
  display: block;
}

/* =========================================
   EVENT INFO BANNER (Dashboard)
   ========================================= */
.event-info-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  padding: 24px 32px;
  margin-bottom: 24px;
}

.event-info-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.event-icon {
  font-size: 48px;
  opacity: 0.9;
}

.event-details {
  flex: 1;
}

.event-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.3;
}

.event-date {
  font-size: 15px;
  opacity: 0.9;
  font-weight: 500;
}

/* =========================================
RESPONSIVE MOBILE
========================================= */
@media screen and (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 1000; /* Di atas overlay */
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .sidebar.active {
    left: 0;
  }
  
  /* Sidebar - Hide by default on mobile */
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .sidebar.active {
    left: 0;
  }
  
  /* Tombol hamburger harus PALING ATAS agar tetap bisa diklik */
  .mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
    margin-right: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    position: relative;
    z-index: 1001; 
  }
  
  .mobile-menu-btn:hover {
    background: #F1F5F9;
  }
  
  /* Main Content - Full Width */
  .main {
    width: 100%;
  }
  
  /* Header harus di BAWAH overlay agar klik di header menutup menu */
  .header {
    position: relative;
    z-index: 998; 
    padding: 0 16px;
    height: 56px;
  }
  
  .header h1 {
    font-size: 16px;
  }
  
  .content {
    padding: 16px;
  }
  
  /* KPI Grid - Stack vertically */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  /* Cards - Adjust padding */
  .card {
    padding: 16px;
    margin-bottom: 16px;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .card-title {
    font-size: 14px;
  }
  
  /* Buttons - Smaller on mobile */
  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  /* Calendar - Adjust */
  .cal-day {
    min-height: 60px;
    padding: 4px;
    font-size: 11px;
  }
  
  .cal-event {
    font-size: 9px;
    padding: 2px 3px;
  }
  
  /* Gantt Chart - Enable scroll */
  .gantt-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Tables - Horizontal scroll */
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px;
    white-space: nowrap;
  }
  
  /* Modal - Full screen */
  .modal {
    width: 90%;
    max-width: 90%;
    padding: 16px;
  }
  
  /* Event Banner */
  .event-info-banner {
    padding: 16px;
  }
  
  .event-icon {
    font-size: 36px;
  }
  
  .event-name {
    font-size: 18px;
  }
  
  .event-date {
    font-size: 13px;
  }
  
  /* Hide non-essential elements */
  .kpi-bar {
    display: none;
  }
}

/* Overlay untuk mobile menu */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999; /* Di bawah sidebar dan tombol hamburger */
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  display: block;
}

/* Desktop - Hide mobile menu button */
@media screen and (min-width: 769px) {
  .mobile-menu-btn {
    display: none;
  }
  
  .mobile-overlay {
    display: none !important;
  }
}
