/* ==========================================================================
   DOMPET KELUARGA AI — UI/UX MASTER RULES STYLING (LINEAR / VERCEL / NOTION)
   Padding: 32px | Radius: 20px | Soft Shadow | Glassmorphism | Generous Whitespace
   ========================================================================== */

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

:root {
  --bg-app: #fafaf9;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f4f4f5;
  --bg-sidebar: #f4f4f5;
  --bg-header: rgba(250, 250, 249, 0.85);

  --sage-primary: #52796f;
  --sage-light: rgba(82, 121, 111, 0.12);
  --sage-glow: rgba(82, 121, 111, 0.25);

  --emerald-soft: #2a9d8f;
  --emerald-light: rgba(42, 157, 143, 0.12);

  --orange-soft: #e76f51;
  --orange-light: rgba(231, 111, 81, 0.12);

  --blue-soft: #4ea8de;
  --blue-light: rgba(78, 168, 222, 0.12);

  --violet-soft: #a855f7;
  --violet-light: rgba(168, 85, 247, 0.12);

  --rose-soft: #f43f5e;
  --rose-light: rgba(244, 63, 94, 0.12);

  --text-main: #18181b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;

  --border-color: rgba(0, 0, 0, 0.07);
  --border-color-hover: rgba(0, 0, 0, 0.15);

  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-backdrop: blur(12px);

  /* Master UI Rules: Padding 32px, Radius 20px */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --main-padding: 32px;

  --sidebar-width-collapsed: 72px;
  --sidebar-width-expanded: 240px;
  --header-height: 72px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-app: #09090b;
  --bg-surface: #141417;
  --bg-surface-hover: #1f1f23;
  --bg-sidebar: #111113;
  --bg-header: rgba(9, 9, 11, 0.85);

  --sage-primary: #84a98c;
  --sage-light: rgba(132, 169, 140, 0.15);
  --sage-glow: rgba(132, 169, 140, 0.3);

  --emerald-soft: #2a9d8f;
  --emerald-light: rgba(42, 157, 143, 0.18);

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-subtle: #52525b;

  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-hover: rgba(255, 255, 255, 0.15);

  --glass-bg: rgba(20, 20, 23, 0.75);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .font-display {
  font-family: 'Outfit', sans-serif;
}

#app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Collapsible Component */
.sidebar {
  width: var(--sidebar-width-collapsed);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  backdrop-filter: var(--glass-backdrop);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar:hover,
.sidebar.expanded {
  width: var(--sidebar-width-expanded);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--sage-primary), var(--emerald-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar:hover .sidebar-logo-text,
.sidebar.expanded .sidebar-logo-text {
  opacity: 1;
}

.sidebar-logo-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--sage-primary);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 20px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}

.nav-item i {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item span {
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar:hover .nav-item span,
.sidebar.expanded .nav-item span {
  opacity: 1;
}

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

.nav-item.active {
  background: var(--sage-light);
  color: var(--sage-primary);
  border: 1px solid var(--sage-glow);
  font-weight: 600;
}

/* Header Component */
.main-wrapper {
  margin-left: var(--sidebar-width-collapsed);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: var(--transition);
}

.top-header {
  height: var(--header-height);
  background: var(--bg-header);
  backdrop-filter: var(--glass-backdrop);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--main-padding);
  position: sticky;
  top: 0;
  z-index: 40;
}

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

.family-title-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
}

.family-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sage-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

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

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.header-icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.user-profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  cursor: pointer;
  transition: var(--transition);
}

.user-profile-chip:hover {
  background: var(--bg-surface-hover);
}

.user-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage-primary), var(--emerald-soft));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

/* Content Area & AI Workspace */
.content-body {
  padding: var(--main-padding);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view-section {
  display: none !important;
}

.view-section.active {
  display: block !important;
  animation: fadeIn 0.25s ease-in-out;
}

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

.ai-workspace-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--main-padding);
  align-items: start;
  min-height: calc(100vh - 136px);
}

@media (max-width: 1100px) {
  .ai-workspace-grid {
    grid-template-columns: 1fr;
  }
}

.ai-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 136px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.ai-status-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--emerald-soft);
  box-shadow: 0 0 8px var(--emerald-soft);
}

.ai-chat-stream {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-greeting-hero {
  text-align: center;
  padding: 40px 20px;
  max-width: 580px;
  margin: auto;
}

.greeting-avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--sage-light);
  color: var(--sage-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 18px auto;
  border: 1px solid var(--sage-glow);
}

.prompt-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.prompt-chip {
  padding: 8px 14px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.prompt-chip:hover {
  border-color: var(--sage-primary);
  background: var(--sage-light);
  color: var(--sage-primary);
}

.chat-msg {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.assistant {
  align-self: flex-start;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-msg.assistant .chat-avatar {
  background: var(--sage-light);
  color: var(--sage-primary);
}

.chat-msg.user .chat-avatar {
  background: var(--blue-light);
  color: var(--blue-soft);
}

.chat-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
}

.chat-msg.assistant .chat-bubble {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.chat-msg.user .chat-bubble {
  background: var(--sage-primary);
  color: #ffffff;
}

.ai-input-bar-wrap {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.ai-input-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  padding: 6px 8px 6px 18px;
}

.ai-input-control {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.summary-panel-sticky {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 104px;
}

.summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.summary-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.total-balance-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--sage-primary);
  letter-spacing: -0.5px;
}

/* Modals System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-in-out;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

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

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-control, .select-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
}

.btn-primary {
  padding: 12px 24px;
  background: var(--sage-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary {
  padding: 12px 24px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE DESIGN (FIT PERFECTLY ON SMARTPHONES / NO ZOOM NEEDED)
   ========================================================================== */

@media (max-width: 768px) {
  :root {
    --main-padding: 14px;
    --header-height: 56px;
    --radius-lg: 14px;
    --radius-md: 12px;
  }

  body {
    padding-bottom: 72px;
  }

  #app-layout {
    flex-direction: column;
  }

  /* Fixed Mobile Glassmorphic Bottom Navigation Bar */
  .sidebar {
    width: 100% !important;
    height: 64px !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-right: none;
    border-top: 1px solid var(--border-color);
    background: var(--glass-bg) !important;
    backdrop-filter: var(--glass-backdrop) !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-around;
    z-index: 999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar-header,
  .sidebar-user {
    display: none !important;
  }

  .sidebar-nav {
    flex-direction: row !important;
    justify-content: space-around !important;
    align-items: center !important;
    width: 100% !important;
    padding: 0 4px !important;
    gap: 0 !important;
    overflow-x: auto;
  }

  .nav-item {
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 6px 8px !important;
    gap: 3px !important;
    border-radius: 8px !important;
  }

  .nav-item i {
    font-size: 17px !important;
    margin: 0 !important;
  }

  .nav-item-text {
    font-size: 9px !important;
    font-weight: 600 !important;
    line-height: 1;
  }

  /* Main Wrapper Takes 100% Mobile Screen Width */
  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .top-header {
    padding: 0 14px !important;
  }

  .main-content {
    padding: 14px 14px 80px 14px !important;
  }

  /* 70/30 Home Grid Stacks to Single Column */
  #home-layout-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .ai-chat-card {
    height: 480px !important;
  }

  /* All Multi-Column Grids Stack Nicely on Mobile */
  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Modals fit smartphone screens comfortably */
  .modal-card {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 18px !important;
    border-radius: var(--radius-md) !important;
  }

  .total-balance-val {
    font-size: 22px !important;
  }

  /* Flex Header Wrappers */
  div[style*="display: flex; justify-content: space-between"] {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Responsive ApexCharts & Log Tables */
  .apexcharts-canvas {
    max-width: 100% !important;
  }

  div[style*="overflow-x: auto"] {
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 11px !important;
  }

  th, td {
    padding: 8px 10px !important;
  }
}

