@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #FF3B30; /* Bright red for alerts */
  --primary-hover: #E02B20;
  --accent: #FF9500; /* Orange */
  --success: #34C759; /* Green */
  --info: #007AFF; /* Blue */
  
  /* Dark Theme Default */
  --bg-app: #080d16;
  --bg-sidebar: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --glass-bg: rgba(15, 23, 42, 0.6);
  --glass-border: rgba(255, 255, 255, 0.05);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.05);
}

/* --- RESET & BASIC --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  transition: var(--transition);
  overflow-x: hidden;
}

.app-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100%;
  min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.brand-logo {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(255, 59, 48, 0.3);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
}

.menu-item a svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.menu-item:hover a, .menu-item.active a {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

body.light-theme .menu-item:hover a, body.light-theme .menu-item.active a {
  background-color: rgba(0, 0, 0, 0.03);
}

.menu-item.active a {
  border-left: 3px solid var(--primary);
  font-weight: 600;
  background-color: rgba(255, 59, 48, 0.08) !important;
  color: var(--primary) !important;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.theme-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
}

.toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-main);
}

/* --- MAIN CONTENT --- */
.main-content {
  padding: 40px;
  overflow-y: auto;
  height: 100vh;
}

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

.header-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.8px;
  margin-bottom: 6px;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* --- BUSINESS BUSINESS TABS --- */
.business-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
  background: rgba(255, 255, 255, 0.02);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-width: fit-content;
}

.biz-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.biz-tab:hover {
  color: var(--text-main);
}

.biz-tab.active {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.25);
}

/* --- METRICS GRID --- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.metric-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  display: block;
}

.metric-footer {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-status {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.status-danger {
  background-color: rgba(255, 59, 48, 0.15) !important;
  color: #FF3B30 !important;
  border-color: rgba(255, 59, 48, 0.3) !important;
}

.status-warn {
  background-color: rgba(255, 149, 0, 0.15) !important;
  color: #FF9500 !important;
  border-color: rgba(255, 149, 0, 0.3) !important;
}

.status-success {
  background-color: rgba(52, 199, 89, 0.15) !important;
  color: #34C759 !important;
  border-color: rgba(52, 199, 89, 0.3) !important;
}

/* Custom Status Focus Borders */
.status-select.status-success:focus { border-color: #34C759 !important; }
.status-select.status-warn:focus { border-color: #FF9500 !important; }
.status-select.status-danger:focus { border-color: #FF3B30 !important; }
.status-select.status-revisi:focus { border-color: #bb8fce !important; }
.status-select.status-info:focus { border-color: #5dade2 !important; }

/* --- PANELS --- */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.dashboard-panel-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 30px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

/* --- TABLES --- */
.table-wrapper {
  overflow-x: auto;
  margin-top: 15px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.01);
}

/* --- SELECT STYLES FOR AUDIT STATUS --- */
.status-select {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

.status-select option {
  background-color: #1e2430; /* Dark color matching card bg */
  color: var(--text-main);
}

.status-select:focus {
  border-color: var(--primary);
}


/* --- REFUND CALCULATOR WRAPPER --- */
.calculator-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 30px;
}

@media (max-width: 1024px) {
  .calculator-grid {
    grid-template-columns: 1fr;
  }
}

.calc-input-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.calc-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.calc-input {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 160px;
  text-align: right;
  outline: none;
}

.calc-input:focus {
  border-color: var(--primary);
}

.refund-summary-box {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.1), rgba(255, 149, 0, 0.1));
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
}

.refund-amount-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.refund-amount-value {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.refund-percent-badge {
  background-color: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}

/* --- FUNNEL BARS --- */
.funnel-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.funnel-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.funnel-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.funnel-progress-bg {
  background-color: rgba(255, 255, 255, 0.05);
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.funnel-progress-fill {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  height: 100%;
  border-radius: 6px;
  transition: width 1s ease-in-out;
}

/* --- ALERTS --- */
.alert-box {
  background-color: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: #FF8882;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* --- AI CHAT WIDGET --- */
.ai-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: inherit;
}

.ai-chat-btn {
  background-color: var(--primary);
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  box-shadow: 0 4px 16px rgba(255, 59, 48, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.ai-chat-btn:hover {
  transform: scale(1.08);
  background-color: #ff4d43;
}

.ai-chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  height: 500px;
  background-color: #1e2430;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.25s ease-out;
}

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

.ai-chat-header {
  background-color: #161a23;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-avatar {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.ai-chat-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.ai-chat-close-btn:hover {
  color: var(--text-main);
}

.ai-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  max-width: 80%;
  padding: 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-msg.received {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  align-self: flex-start;
  border-top-left-radius: 2px;
}

.ai-msg.sent {
  background-color: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-top-right-radius: 2px;
}

.ai-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background-color: #161a23;
  display: flex;
  gap: 8px;
}

.ai-chat-input-area input {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

.ai-chat-input-area input:focus {
  border-color: var(--primary);
}

.ai-chat-input-area button {
  background-color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.ai-chat-input-area button:hover {
  background-color: #ff4d43;
}

/* --- COLLAPSED SIDEBAR --- */
.app-container.collapsed {
  grid-template-columns: 80px 1fr !important;
}

.app-container.collapsed .sidebar {
  padding: 30px 12px !important;
  align-items: center;
}

.app-container.collapsed .sidebar .brand-name {
  display: none !important;
}

.app-container.collapsed .sidebar .brand {
  justify-content: center !important;
  margin-bottom: 30px !important;
}

.app-container.collapsed .sidebar .menu-item a {
  justify-content: center !important;
  padding: 12px !important;
}

.app-container.collapsed .sidebar .menu-item a span {
  display: none !important;
}

.app-container.collapsed .sidebar .theme-toggle {
  justify-content: center !important;
  padding: 10px !important;
}

.app-container.collapsed .sidebar .theme-toggle span {
  display: none !important;
}

.app-container.collapsed .sidebar .sidebar-footer-text {
  display: none !important;
}

/* --- SORTABLE TABLES --- */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

th.sortable:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

body.light-theme th.sortable:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.sort-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: var(--text-light);
}

/* Custom Status and Urgency Tag Colors */
.status-revisi {
  background-color: rgba(187, 143, 206, 0.15) !important;
  color: #bb8fce !important;
  border-color: rgba(187, 143, 206, 0.3) !important;
}

.status-info {
  background-color: rgba(93, 173, 226, 0.15) !important;
  color: #5dade2 !important;
  border-color: rgba(93, 173, 226, 0.3) !important;
}

/* --- CALENDAR VIEW --- */
.calendar-day-cell {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 54px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
  cursor: pointer;
}

body.light-theme .calendar-day-cell {
  background-color: rgba(0, 0, 0, 0.01);
}

.calendar-day-cell:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

body.light-theme .calendar-day-cell:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.calendar-day-cell.empty-day {
  background-color: transparent !important;
  border-color: transparent !important;
  cursor: default;
}

.calendar-day-cell.today {
  border-color: var(--primary) !important;
  background-color: rgba(255, 59, 48, 0.05) !important;
}

.calendar-day-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
}

.calendar-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.calendar-task-dot {
  height: 4px;
  border-radius: 2px;
  width: 100%;
}

.dot-success { background-color: #2ecc71; }
.dot-warn { background-color: #f1c40f; }
.dot-revisi { background-color: #bb8fce; }
.dot-danger { background-color: #e74c3c; }

