/* ===== RESET & VARIABLES ===== */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
:root { 
  --primary: #2563eb; 
  --primary-dark: #1e40af; 
  --car-color: #f59e0b; 
  --car-bg: #fef3c7; 
  --room-color: #10b981; 
  --room-bg: #d1fae5; 
  --bg: #f3f4f6; 
  --card: #ffffff; 
  --text: #1f2937; 
  --text-light: #6b7280; 
  --border: #e5e7eb; 
  --danger: #ef4444; 
  --success: #10b981;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  --backdrop-blur: blur(12px);
}

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

/* ===== SIDEBAR ===== */
.sidebar { 
  width: 260px; 
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); 
  background-size: 100% 200%; 
  color: #fff; 
  padding: 24px 0; 
  position: fixed; 
  height: 100vh; 
  overflow-y: auto; 
  display: flex; 
  flex-direction: column; 
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15); 
  animation: slideInLeft 0.6s ease-out; 
  z-index: 1000; 
}
@keyframes slideInLeft { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; }}
.sidebar-header { padding: 0 24px 24px; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 16px; }
.sidebar-header h1 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.sidebar-header p { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.nav-menu { list-style: none; }
.nav-item { 
  padding: 14px 24px; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  font-size: 14px; 
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  border-left: 3px solid transparent; 
  position: relative; 
  overflow: hidden; 
  margin: 4px 0; 
}
.nav-item::before { 
  content: ''; 
  position: absolute; 
  top: 50%; 
  left: 50%; 
  width: 0; 
  height: 0; 
  border-radius: 50%; 
  background: rgba(37, 99, 235, 0.3); 
  transform: translate(-50%, -50%); 
  transition: width 0.6s, height 0.6s; 
}
.nav-item:hover::before { width: 300px; height: 300px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.08); transform: translateX(8px); border-left-color: rgba(37, 99, 235, 0.5); }
.nav-item:hover .nav-icon { transform: scale(1.2) rotate(5deg); transition: transform 0.3s ease; }
.nav-item.active { 
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.05) 100%); 
  border-left-color: var(--primary); 
  color: #fff; 
  font-weight: 600; 
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2); 
}
.nav-item.active::after { 
  content: ''; 
  position: absolute; 
  left: 0; 
  top: 0; 
  bottom: 0; 
  width: 3px; 
  background: var(--primary); 
  box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary); 
  animation: pulseGlow 2s ease-in-out infinite; 
}
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary); } 50% { box-shadow: 0 0 15px var(--primary), 0 0 30px var(--primary); }}
.nav-icon { font-size: 18px; width: 24px; text-align: center; transition: all 0.3s ease; display: inline-block; }
.nav-item:nth-child(1) { animation: fadeInLeft 0.4s ease-out 0.1s both; }
.nav-item:nth-child(2) { animation: fadeInLeft 0.4s ease-out 0.2s both; }
.nav-item:nth-child(3) { animation: fadeInLeft 0.4s ease-out 0.3s both; }
.nav-item:nth-child(4) { animation: fadeInLeft 0.4s ease-out 0.4s both; }
.nav-item:nth-child(5) { animation: fadeInLeft 0.4s ease-out 0.5s both; }
.nav-item:nth-child(6) { animation: fadeInLeft 0.4s ease-out 0.6s both; }
@keyframes fadeInLeft { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); }}
#userAvatar { 
  width: 40px; 
  height: 40px; 
  border-radius: 50%; 
  background: var(--primary); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-weight: bold; 
  position: relative; 
  transition: all 0.3s ease; 
}
#userAvatar::before { 
  content: ''; 
  position: absolute; 
  inset: -3px; 
  border-radius: 50%; 
  background: linear-gradient(45deg, var(--primary), var(--success)); 
  z-index: -1; 
  animation: rotate 3s linear infinite; 
}
@keyframes rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); }}
#userInfo:hover #userAvatar { transform: scale(1.1); }
#userInfo button { transition: all 0.3s ease; }
#userInfo button:hover { color: var(--danger) !important; transform: rotate(90deg) scale(1.2); }
#loginButton .btn { transition: all 0.3s ease; position: relative; overflow: hidden; }
#loginButton .btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4); }

/* ===== HAMBURGER MENU ===== */
.hamburger-menu { 
  display: none; 
  position: fixed; 
  top: 20px; 
  left: 20px; 
  z-index: 1100; 
  background: var(--primary); 
  border: none; 
  border-radius: 8px; 
  width: 44px; 
  height: 44px; 
  cursor: pointer; 
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4); 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 5px; 
  padding: 10px; 
  transition: all 0.3s ease; 
}
.hamburger-menu span { display: block; width: 22px; height: 3px; background: white; border-radius: 3px; transition: all 0.3s ease; }
.hamburger-menu.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-menu.active span:nth-child(2) { opacity: 0; }
.hamburger-menu.active span:nth-child(3) { transform: rotate(-45deg) translate(7px, -7px); }
.hamburger-menu:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay { 
  display: none; 
  position: fixed; 
  inset: 0; 
  background: rgba(0, 0, 0, 0.5); 
  z-index: 999; 
  opacity: 0; 
  transition: opacity 0.3s ease; 
  backdrop-filter: blur(2px); 
  -webkit-backdrop-filter: blur(2px); 
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ===== MAIN CONTENT ===== */
.main { margin-left: 260px; flex: 1; padding: 24px 32px; min-height: 100vh; transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar h2 { font-size: 24px; font-weight: 700; }
.topbar .date-info { color: var(--text-light); font-size: 14px; }

/* ===== BUTTONS ===== */
.btn { padding: 10px 18px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s; text-align: center; justify-content: center; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-dark { background: #4b5563; color: #ffffff; }
.btn-dark:hover { background: #374151; }

/* ===== SECTIONS ===== */
.section { display: none; animation: fadeIn 0.3s; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== CARDS & GRIDS ===== */
.status-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; margin-bottom: 32px; }
.status-card { 
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%); 
  backdrop-filter: blur(12px); 
  border-radius: 16px; 
  padding: 28px; 
  border: 1px solid var(--glass-border); 
  box-shadow: var(--glass-shadow); 
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}
.status-card.car-status { border-left: 4px solid var(--car-color); }
.status-card.room-status { border-left: 4px solid var(--room-color); }
.status-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15); }
.status-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.status-card-header h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 25px; font-size: 14px; font-weight: 700; transition: all 0.3s; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.status-badge.available { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #ffffff; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4); }
.status-badge.available .badge-dot { background: #ffffff; box-shadow: 0 0 10px rgba(255,255,255,0.8); }
.status-badge.booked { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); color: #ffffff; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4); }
.status-badge.booked .badge-dot { background: #ffffff; box-shadow: 0 0 10px rgba(255,255,255,0.8); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(0.95); } }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
.status-badge.partial { background: #fef3c7; color: #d97706; }
.badge-text { font-weight: 600; }
.status-card-content { padding: 8px 0; }
.status-info { display: flex; flex-direction: column; gap: 12px; }
.info-item { display: flex; flex-direction: column; gap: 4px; }
.info-label { font-size: 13px; color: var(--text-light); font-weight: 500; }
.info-value { font-size: 14px; color: var(--text); font-weight: 600; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); padding: 20px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border-left: 4px solid var(--primary); }
.stat-card.car { border-left-color: var(--car-color); }
.stat-card.room { border-left-color: var(--room-color); }
.stat-label { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }

.content-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.card { background: var(--glass-bg); backdrop-filter: var(--backdrop-blur); -webkit-backdrop-filter: var(--backdrop-blur); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); padding: 20px; border-radius: 12px; }
.card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px 0 rgba(31, 38, 135, 0.2); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 12px; }
.card-title { font-size: 16px; font-weight: 600; }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f9fafb; font-weight: 600; color: var(--text-light); font-size: 12px; text-transform: uppercase; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; text-align: center; }
.badge-car { background: var(--car-bg); color: var(--car-color); }
.badge-room { background: var(--room-bg); color: var(--room-color); }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-approved { background: #d1fae5; color: #047857; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }

/* ===== HEATMAP ===== */
.cal-maintenance-count { font-size: 10px; color: #ef4444; font-weight: 600; background: rgba(239, 68, 68, 0.1); padding: 2px 8px; border-radius: 12px; margin-top: 4px; text-align: center; }
.cal-day-cell.has-maintenance { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); border: 2px solid #ef4444; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }
.cal-day-cell.has-maintenance:hover { background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%); }
.heatmap-grid { display: grid; grid-template-columns: 80px repeat(7, 1fr); gap: 6px; align-items: center; }
.heatmap-label { font-size: 12px; font-weight: 600; color: var(--text); text-align: right; padding-right: 8px; }
.heatmap-day-header { font-size: 11px; font-weight: 600; color: var(--text-light); text-align: center; padding: 4px 0; }
.heatmap-cell { aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.2s ease; position: relative; background: #e5e7eb; color: var(--text-light); }
.heatmap-cell:hover { transform: scale(1.1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); z-index: 10; }
.heatmap-cell.level-0 { background: #e5e7eb; color: #9ca3af; }
.heatmap-cell.level-1 { background: #facc15; color: #713f12; }
.heatmap-cell.level-2 { background: #f97316; color: white; }
.heatmap-legend { display: flex; justify-content: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-light); flex-wrap: wrap; }
.heatmap-legend span { display: inline-flex; align-items: center; gap: 4px; }
.heatmap-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.heatmap-week-range { background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%); padding: 6px 12px; border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; text-align: center; flex: 1; }
.heatmap-nav button:disabled { opacity: 0.5; cursor: not-allowed; }
.heatmap-period { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; padding: 8px 12px; background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%); border-radius: 8px; border-left: 3px solid var(--primary); font-size: 11px; color: var(--text); text-align: center; }
.heatmap-period .period-icon { font-size: 10px; }
.heatmap-period .period-text { font-weight: 600; }
.metric-card:has(#heatmapContainer) { padding: 16px 20px !important; }
.metric-card:has(#heatmapContainer) .metric-label { font-size: 13px !important; margin-bottom: 12px !important; }
.metric-card:has(#heatmapContainer) .heatmap-grid { grid-template-columns: 50px repeat(7, 1fr) !important; gap: 4px !important; }
.metric-card:has(#heatmapContainer) .heatmap-label { font-size: 10px !important; padding-right: 4px !important; }
.metric-card:has(#heatmapContainer) .heatmap-day-header { font-size: 9px !important; padding: 2px 0 !important; }
.metric-card:has(#heatmapContainer) .heatmap-cell { font-size: 10px !important; border-radius: 4px !important; aspect-ratio: auto !important; height: 28px !important; }
.metric-card:has(#heatmapContainer) .heatmap-period { margin-top: 8px !important; padding: 6px 8px !important; font-size: 9px !important; }
.metric-card:has(#heatmapContainer) .heatmap-period .period-icon { font-size: 10px !important; }
.metric-card:has(#heatmapContainer) .heatmap-legend { gap: 8px !important; font-size: 9px !important; margin-top: 6px !important; padding-top: 6px !important; }
.heatmap-cell::after { content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #1f2937; color: white; padding: 4px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s; margin-bottom: 4px; z-index: 20; }
.heatmap-cell:hover::after { opacity: 1; }

/* ===== GLASSMORPHISM ===== */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 32px; }
.metric-card { background: linear-gradient(270deg, rgba(59, 130, 246, 0.15) 0%, rgba(255, 255, 255, 1) 100%); backdrop-filter: blur(12px); border: 1px solid rgba(59, 130, 246, 0.3); border-radius: 16px; padding: 24px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); transition: all 0.3s ease; position: relative; overflow: hidden; }
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%); }
.metric-card:hover { transform: translateY(-6px); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15); }
.metric-label { font-size: 13px; color: var(--text-light); margin-bottom: 8px; font-weight: 500; }
.metric-value { font-size: 32px; font-weight: 700; color: var(--text); margin-bottom: 8px; background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.metric-card.stock-style { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 24px !important; min-height: 180px; }
.metric-card.stock-style .metric-label { font-size: 14px; color: var(--text-light); margin-bottom: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-card.stock-style .metric-value { font-size: 72px; font-weight: 700; color: var(--text); margin-bottom: 0; background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1; }

.chart-section { grid-column: 1 / -1; margin-bottom: 32px; animation: fadeIn 0.5s ease-out both; }
.chart-card { background: var(--glass-bg); backdrop-filter: blur(12px); border-radius: 16px; padding: 24px; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); animation: fadeIn 0.6s ease-out both; will-change: opacity, transform; transform-origin: center top; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.chart-title { font-size: 18px; font-weight: 700; color: var(--text); }
.chart-filter select { padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: white; cursor: pointer; font-size: 13px; width: 100%; }
.chart-container { position: relative; height: 300px; width: 100%; }

/* ===== CALENDAR ===== */
.calendar-wrapper-full { background: linear-gradient(135deg, #4a6fa5 0%, #6b8cae 100%); border-radius: 12px 12px 0 0; padding: 16px; margin: -16px -16px 0 -16px; }
.calendar-header-full { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.calendar-month-full { flex: 1; text-align: center; color: white; font-size: 18px; font-weight: 700; padding: 10px 24px; background: rgba(255, 255, 255, 0.1); border-radius: 8px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.calendar-nav-btn-full { width: 40px; height: 40px; border: 2px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.1); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; color: white; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.calendar-nav-btn-full:hover { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.5); transform: scale(1.05); }
.advanced-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day-header { text-align: center; padding: 8px; font-weight: 600; color: var(--text-light); font-size: 13px; }
.cal-day-cell { aspect-ratio: 1; background: var(--bg); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; position: relative; min-height: 70px; padding: 6px; }
.cal-day-cell:hover { background: #e5e7eb; transform: translateY(-2px); }
.cal-day-cell.has-booking { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); border: 2px solid #f59e0b; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3); }
.cal-day-cell.has-booking:hover { background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%); }
.cal-day-cell.empty { background: transparent; cursor: default; }
.cal-day-cell.empty:hover { transform: none; background: transparent; }
.cal-day-number { font-weight: 700; color: var(--text); font-size: 18px; margin-bottom: 4px; }
.cal-day-cell.today .cal-day-number { background: var(--primary); color: white; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cal-booking-count { font-size: 11px; color: var(--primary); font-weight: 600; background: rgba(37, 99, 235, 0.1); padding: 2px 8px; border-radius: 12px; text-align: center; }

/* ===== SORTABLE TABLE ===== */
#section-riwayat th { background: linear-gradient(135deg, #4a6fa5 0%, #6b8cae 100%) !important; color: #ffffff !important; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid #3d5a80; }
#section-riwayat th.sortable:hover { background: linear-gradient(135deg, #3d5a80 0%, #5a7fa0 100%) !important; }
#section-riwayat th .sort-icon { color: rgba(255, 255, 255, 0.8); }
#section-riwayat th.sort-asc .sort-icon::after, #section-riwayat th.sort-desc .sort-icon::after { color: #ffffff; }
.sortable { cursor: pointer; user-select: none; position: relative; transition: background 0.2s; }
.sortable:hover { background: #e5e7eb !important; }
.sort-icon { font-size: 10px; margin-left: 4px; color: #9ca3af; }
.sort-asc .sort-icon::after { content: ' ↑'; color: var(--primary); font-weight: bold; }
.sort-desc .sort-icon::after { content: ' ↓'; color: var(--primary); font-weight: bold; }
.sort-asc .sort-icon, .sort-desc .sort-icon { color: var(--primary); }

/* ===== MODALS ===== */
.detail-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 2000; align-items: center; justify-content: center; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.detail-modal-overlay.active { display: flex; }
.detail-modal-content { background: #111827; color: white; border-radius: 16px; padding: 24px; min-width: 320px; max-width: 400px; width: 90%; box-shadow: 0 20px 40px rgba(0,0,0,0.4); position: relative; }
.detail-modal-title { font-size: 13px; font-weight: 600; color: #9ca3af; margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-booking-item { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #374151; }
.detail-booking-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.detail-booking-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: #ffffff; }
.detail-booking-time { font-size: 13px; color: #d1d5db; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.detail-booking-desc { font-size: 12px; color: #9ca3af; }
.detail-close-btn { position: absolute; top: 16px; right: 16px; background: #374151; border: none; color: white; font-size: 18px; cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: all 0.2s; }
.detail-close-btn:hover { background: #4b5563; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; }
.modal { background: var(--card); border-radius: 12px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; transition: border-color 0.2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.type-option { padding: 14px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; text-align: center; transition: all 0.2s; }
.type-option:hover { border-color: var(--primary); }
.type-option.selected { border-color: var(--primary); background: #eff6ff; }
.type-option .icon { font-size: 28px; margin-bottom: 4px; }
.type-option .label { font-size: 13px; font-weight: 600; }

/* ===== EMPTY & LOADING STATES ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.loading { text-align: center; padding: 20px; color: var(--text-light); }

/* ===== TOOLTIP ===== */
.calendar-tooltip { position: absolute; background: #1f2937; color: white; padding: 12px; border-radius: 8px; font-size: 12px; z-index: 9999; pointer-events: none; box-shadow: 0 8px 16px rgba(0,0,0,0.4); min-width: 220px; max-width: 280px; display: none; border: 1px solid #374151; }
.calendar-tooltip strong { color: #60a5fa; display: block; margin-bottom: 4px; font-size: 13px; }
.calendar-tooltip .time { color: #fbbf24; font-size: 11px; margin-bottom: 4px; }
.calendar-tooltip .desc { color: #d1d5db; font-style: italic; font-size: 11px; }

/* ===== TOAST ===== */
.toast { min-width: 250px; padding: 16px 20px; border-radius: 8px; color: white; font-size: 14px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s ease-out forwards; opacity: 0; transform: translateX(100%); }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #2563eb; }
@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ==========================================================================
MOBILE RESPONSIVE OPTIMIZATION
========================================================================== */
@media (max-width: 1024px) {
  .hamburger-menu { display: flex; }
  .sidebar { transform: translateX(-100%); z-index: 1000; box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3); }
  .sidebar.active { transform: translateX(0); }
  .main { margin-left: 0; padding: 80px 16px 24px; }
  .topbar { padding-left: 60px; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
  .topbar h2 { font-size: 20px; }
  .metrics-grid, .status-cards-grid, .stats-grid { grid-template-columns: 1fr; gap: 16px; }
  .metric-card { padding: 20px; min-height: auto; }
  .metric-value { font-size: 36px; }
  .metric-label { font-size: 13px; }
  .status-card { padding: 20px; }
  .chart-container { height: 250px; }
  .chart-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .content-grid { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns: 1fr 1fr 1fr 1fr auto auto"],
  div[style*="grid-template-columns: 1fr 1fr 1fr 1fr 1fr auto auto"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .sidebar { width: 85vw; max-width: 300px; }
  .main { padding: 70px 12px 16px; }
  .topbar { padding-left: 55px; }
  .topbar h2 { font-size: 18px; word-break: break-word; }
  .date-info { font-size: 12px; }
  .card, .stat-card, .status-card { padding: 16px; }
  .card-title { font-size: 15px; }
  .metric-value { font-size: 32px; }
  .metric-label { font-size: 12px; }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
  table { min-width: 600px; font-size: 13px; }
  th, td { padding: 10px 8px; font-size: 12px; white-space: nowrap; }
  .form-row { grid-template-columns: 1fr; gap: 16px; }
  .btn { padding: 12px 16px; font-size: 14px; width: 100%; }
  .btn-sm { width: auto; padding: 6px 12px; font-size: 12px; }
  .modal { max-width: 95vw; margin: 10px; border-radius: 16px; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 16px; flex-direction: column-reverse; gap: 12px; }
  .modal-footer .btn { width: 100%; justify-content: center; }
  .advanced-calendar-grid { gap: 4px; }
  .cal-day-cell { min-height: 50px; padding: 4px; }
  .cal-day-number { font-size: 14px; }
  .cal-booking-count { font-size: 9px; padding: 2px 4px; }
  .calendar-header-full { gap: 8px; }
  .calendar-month-full { font-size: 15px; padding: 8px 12px; }
  .calendar-nav-btn-full { width: 36px; height: 36px; }
  .heatmap-grid { grid-template-columns: 40px repeat(7, 1fr); gap: 3px; }
  .heatmap-label { font-size: 9px; padding-right: 2px; }
  .heatmap-day-header { font-size: 9px; }
  .heatmap-cell { font-size: 10px; height: 32px; border-radius: 4px; }
  .metric-card:has(#heatmapContainer) .heatmap-grid { grid-template-columns: 35px repeat(7, 1fr) !important; gap: 2px !important; }
  .metric-card:has(#heatmapContainer) .heatmap-label { font-size: 8px !important; }
  .metric-card:has(#heatmapContainer) .heatmap-cell { height: 24px !important; font-size: 9px !important; }
  .metric-card.stock-style { min-height: 120px; padding: 20px 16px !important; }
  .metric-card.stock-style .metric-value { font-size: 48px; }
  .metric-card.stock-style .metric-label { font-size: 12px; }
}

@media (max-width: 480px) {
  .hamburger-menu { top: 12px; left: 12px; width: 40px; height: 40px; }
  .main { padding: 65px 8px 16px; }
  .topbar { padding-left: 50px; }
  .topbar h2 { font-size: 16px; }
  .date-info { font-size: 11px; }
  .card, .stat-card, .status-card { padding: 12px; border-radius: 10px; }
  .metric-value { font-size: 28px; }
  .metric-label { font-size: 11px; }
  .btn { padding: 12px; font-size: 14px; min-height: 44px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }
  table { font-size: 11px; min-width: 500px; }
  th, td { padding: 8px 6px; }
  input, select, textarea { font-size: 16px !important; min-height: 44px; }
  .badge { padding: 4px 8px; font-size: 10px; }
  .status-badge { padding: 8px 12px; font-size: 12px; }
  .toast { min-width: auto; width: calc(100% - 24px); right: 12px; left: 12px; padding: 12px 16px; font-size: 13px; }
  .detail-modal-content { min-width: 90vw; padding: 20px; }
}

/* =========================================================
   PERBAIKAN KHUSUS TABEL MOBILE (Riwayat, User, Aset, Audit)
   ========================================================= */
@media (max-width: 768px) {
  /* 1. Wrapper tabel dengan scroll vertikal & horizontal yang mulus */
  .table-wrapper {
    position: relative;
    max-height: 65vh; /* Batasi tinggi agar bisa scroll vertikal di dalam tabel */
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Scroll mulus di iOS */
    border-radius: 8px;
    border: 1px solid var(--border);
  }

  /* 2. Sticky Header: Judul kolom tetap terlihat saat scroll ke bawah */
  table thead {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f9fafb; /* Background solid agar teks di bawahnya tidak tembus */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  }

  table th {
    white-space: nowrap;
    font-size: 11px;
    padding: 12px 10px;
    position: sticky;
    top: 0;
  }

  /* 3. Truncate teks panjang (Keperluan, Detail, Fasilitas) agar tabel tidak meledak */
  table td {
    white-space: nowrap;
    max-width: 140px; /* Batasi lebar maksimal kolom teks */
    overflow: hidden;
    text-overflow: ellipsis; /* Tambahkan "..." di akhir teks */
    padding: 10px 8px;
    font-size: 13px;
  }

  /* 4. Visual Hint: Petunjuk bahwa tabel bisa di-geser ke samping */
  .table-wrapper::after {
    content: '← Geser →';
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    pointer-events: none; /* Agar tidak mengganggu klik */
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    animation: pulseHint 2.5s ease-in-out infinite;
    z-index: 15;
  }

  @keyframes pulseHint {
    0%, 100% { opacity: 0.7; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(-4px); }
  }

  /* 5. Perbesar area sentuh tombol aksi (Edit/Hapus/Lihat) menjadi minimal 44x44px */
  .btn-sm {
    min-width: 40px;
    min-height: 40px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 18px; /* Perbesar ikon agar jelas */
    border-radius: 8px;
  }

  /* Pastikan container tombol tidak wrap/turun ke bawah */
  td div[style*="display:flex"] {
    gap: 8px !important;
    flex-wrap: nowrap !important;
  }

  /* 6. Khusus Audit Log: Kolom Detail seringkali sangat panjang */
  #auditLogsTable td:nth-child(7) {
    max-width: 100px;
  }
}

/* ===== TOUCH OPTIMIZATION ===== */
@media (hover: none) and (pointer: coarse) {
  .nav-item { padding: 16px 24px; min-height: 48px; }
  .btn, button, select, input, textarea { min-height: 44px; }
  .cal-day-cell { min-height: 60px; }
  .nav-item:hover, .card:hover, .stat-card:hover, .status-card:hover, .btn:hover, .cal-day-cell:hover {
    transform: none !important;
    box-shadow: inherit !important;
    background: inherit !important;
  }
  .calendar-tooltip, .heatmap-cell::after { display: none !important; }
}

/* =========================================================
   PERBAIKAN OVERLAP: Distribusi per Minggu Chart
   ========================================================= */

/* Tambah spacing pada teks subtitle */
.metric-card p[style*="font-size: 11px"],
.metric-card div[style*="font-size: 11px"][style*="font-style: italic"] {
  margin-bottom: 16px !important;
  display: block !important;
  line-height: 1.4 !important;
}

/* Tambah spacing pada container chart bars */
.metric-card div[style*="display: flex"][style*="align-items: flex-end"] {
  margin-top: 20px !important;
  padding-top: 8px !important;
  min-height: 60px !important;
}

/* Perbaiki posisi week-number agar tidak overlap */
.week-number {
  top: -18px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  z-index: 10 !important;
}

/* Pastikan bar container memiliki posisi relative */
.metric-card div[style*="height: 40px"] {
  position: relative !important;
  margin-top: 24px !important;
}

/* Responsive untuk mobile */
@media (max-width: 768px) {
  .metric-card p[style*="font-size: 11px"],
  .metric-card div[style*="font-size: 11px"][style*="font-style: italic"] {
    margin-bottom: 12px !important;
    font-size: 10px !important;
  }
  
  .metric-card div[style*="display: flex"][style*="align-items: flex-end"] {
    margin-top: 16px !important;
    min-height: 50px !important;
  }
  
  .week-number {
    top: -16px !important;
    font-size: 10px !important;
  }
}

@media (max-width: 480px) {
  .metric-card p[style*="font-size: 11px"],
  .metric-card div[style*="font-size: 11px"][style*="font-style: italic"] {
    margin-bottom: 10px !important;
    font-size: 9px !important;
  }
  
  .metric-card div[style*="display: flex"][style*="align-items: flex-end"] {
    margin-top: 14px !important;
    min-height: 45px !important;
  }
  
  .week-number {
    top: -14px !important;
    font-size: 9px !important;
  }
}
