/**
 * Juragankosan — Main Stylesheet & Design Tokens
 */

:root {
  /* Brand Emerald Palette */
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --primary-300: #6ee7b7;
  --primary-400: #34d399;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-800: #065f46;
  --primary-900: #064e3b;

  /* Accent Colors */
  --blue-50: #eff6ff;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --amber-50: #fffbeb;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --rose-50: #fff1f2;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --purple-50: #faf5ff;
  --purple-500: #a855f7;
  --purple-600: #9333ea;

  /* WhatsApp Brand Color */
  --wa-green: #25d366;
  --wa-green-hover: #1ebd5b;

  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  /* Sidebar */
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* Light Theme (Default) */
[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  --badge-emerald-bg: #d1fae5;
  --badge-emerald-text: #065f46;
  --badge-blue-bg: #dbeafe;
  --badge-blue-text: #1e40af;
  --badge-amber-bg: #fef3c7;
  --badge-amber-text: #92400e;
  --badge-danger-bg: #fee2e2;
  --badge-danger-text: #991b1b;
  --badge-neutral-bg: #e2e8f0;
  --badge-neutral-text: #334155;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #111827;
  --bg-surface-subtle: #1e293b;
  --bg-card: #151e32;
  --border-color: #243048;
  --border-subtle: #1e293b;

  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);

  --badge-emerald-bg: rgba(16, 185, 129, 0.2);
  --badge-emerald-text: #6ee7b7;
  --badge-blue-bg: rgba(59, 130, 246, 0.2);
  --badge-blue-text: #93c5fd;
  --badge-amber-bg: rgba(245, 158, 11, 0.2);
  --badge-amber-text: #fcd34d;
  --badge-danger-bg: rgba(239, 68, 68, 0.2);
  --badge-danger-text: #fca5a5;
  --badge-neutral-bg: rgba(148, 163, 184, 0.2);
  --badge-neutral-text: #cbd5e1;
}

/* CSS Reset & Baseline */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

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

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-menu {
  flex: 1;
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.6875rem 0.875rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.nav-label {
  flex: 1;
}

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

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.nav-item.active .nav-icon {
  color: #ffffff;
}

.nav-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.125rem 0.45rem;
  border-radius: var(--radius-full);
}

.nav-badge.badge-emerald {
  background-color: var(--primary-100);
  color: var(--primary-800);
}

.nav-badge.badge-amber {
  background-color: var(--amber-50);
  color: var(--amber-600);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.app-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-weight: 500;
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary-500);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.version-tag {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* Main Content Wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-mobile-logo {
  display: none;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-main);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.menu-toggle-btn svg {
  width: 24px;
  height: 24px;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.breadcrumb-item {
  color: var(--text-muted);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

.breadcrumb-current {
  font-weight: 600;
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-action-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.1rem;
}

.topbar-action-btn:hover {
  background-color: var(--bg-surface-subtle);
  border-color: var(--primary-500);
}

/* Page Content Container */
.page-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* View Header */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.view-header-title {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.greeting-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background-color: var(--primary-50);
  color: var(--primary-700);
  font-size: 0.75rem;
  font-weight: 700;
  width: fit-content;
  margin-bottom: 0.35rem;
}

[data-theme="dark"] .greeting-badge {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--primary-400);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.view-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Footer */
.app-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  margin-top: auto;
}

.footer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Mobile Bottom Navigation (Hidden on desktop, elegant scrollable tab bar on mobile) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  z-index: 95;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  align-items: center;
  justify-content: flex-start;
  padding-left: 6px;
  padding-right: 6px;
  gap: 2px;
}

.mobile-bottom-nav::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.mobile-nav-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  flex: 0 0 auto;
  min-width: 62px;
  max-width: 72px;
  height: 100%;
  min-height: 48px;
  padding: 4px 6px;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  user-select: none;
  touch-action: manipulation;
  border-radius: var(--radius-md);
  text-decoration: none;
}

.mobile-nav-icon {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-fast);
}

.mobile-nav-item.active {
  color: var(--primary-600);
  font-weight: 700;
}

.mobile-nav-item.active .mobile-nav-icon {
  transform: translateY(-1px);
}

[data-theme="dark"] .mobile-nav-item.active {
  color: var(--primary-400);
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
  :root {
    --sidebar-width: 230px;
  }
  .page-content {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    display: none; /* Hide sidebar completely in mobile - Bottom Nav handles all 7 tabs */
  }
  .sidebar.open {
    transform: translateX(-100%);
    display: none;
  }
  .main-wrapper {
    margin-left: 0 !important;
    padding-bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  /* Eliminate double menu: Hide hamburger menu on mobile */
  .menu-toggle-btn {
    display: none !important;
  }
  /* Show clean topbar mobile logo icon */
  .topbar-mobile-logo {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 26px !important;
    height: 26px !important;
    border-radius: 7px;
    margin-right: 4px;
    flex-shrink: 0;
  }
  .topbar {
    height: 56px !important;
    padding: 0 0.875rem !important;
  }
  .topbar-left {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    min-width: 0 !important;
    flex: 1 !important;
  }
  .topbar-right {
    gap: 0.375rem !important;
    flex-shrink: 0 !important;
  }
  .topbar-action-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.95rem !important;
    border-radius: 9px !important;
  }
  /* Topbar title: hide "Juragankosan /" prefix and force 1 clean line with ellipsis */
  .topbar-breadcrumb {
    min-width: 0 !important;
    flex: 1 !important;
    gap: 0 !important;
  }
  .topbar-breadcrumb .breadcrumb-item,
  .topbar-breadcrumb .breadcrumb-separator {
    display: none !important;
  }
  .topbar-breadcrumb .breadcrumb-current {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    max-width: calc(100vw - 145px) !important;
    line-height: 1.2 !important;
  }
  .mobile-bottom-nav {
    display: flex !important;
  }
  .page-content {
    padding: 0.875rem 0.875rem calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
  .view-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.625rem !important;
  }
  .view-header-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .view-header-actions .btn {
    flex: 1 1 auto !important;
    min-height: 38px !important;
    justify-content: center !important;
    font-size: 0.8125rem !important;
  }
}

/* Global Utilities */
.hidden {
  display: none !important;
}
