/* ==========================================================
   SI-KESBUMIL - Main Stylesheet
   Sistem Monitoring Kesehatan Ibu Hamil
   ========================================================== */

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

:root {
  /* Primary Colors */
  --primary: #5846eb;
  --primary-hover: #4835d4;
  --primary-light: #edeafe;
  --primary-subtle: #f4f2ff;

  /* Status & Accent Colors */
  --success: #10b981;
  --success-light: #e6f9f0;
  --warning: #f59e0b;
  --warning-light: #fff8eb;
  --danger: #ef4444;
  --danger-light: #feeaeb;
  --info: #3b82f6;
  --info-light: #eff6ff;
  --teal: #14b8a6;
  --teal-light: #e6fffa;
  --pink: #ec4899;
  --pink-light: #fdf2f8;
  --orange: #f97316;
  --orange-light: #fff7ed;

  /* Neutral Colors */
  --bg-app: #f6f8fd;
  --bg-card: #ffffff;
  --text-main: #1e2538;
  --text-muted: #7e8b9b;
  --text-light: #a0aec0;
  --border-color: #e5e9f2;
  --border-focus: #5846eb;

  /* Layout Constants */
  --sidebar-width: 250px;
  --header-height: 72px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card: 0 4px 20px -2px rgba(90, 107, 130, 0.07);
  --shadow-hover: 0 8px 25px -4px rgba(88, 70, 235, 0.12);

  /* Transitions */
  --transition: all 0.2s ease-in-out;
}

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* ==========================================================
   SIDEBAR STYLING
   ========================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 150;
  padding: 20px 16px;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar Header & Close Button */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f0f2f8;
  padding-bottom: 16px;
  margin-bottom: 18px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.logo-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #edeafe 0%, #fce7f3 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(88, 70, 235, 0.15);
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #4338ca;
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: var(--transition);
}

.sidebar-close-btn:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

/* Navigation List */
.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #4b5563;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
  color: #6b7280;
  transition: var(--transition);
}

.nav-link:hover {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.nav-link:hover svg {
  color: var(--primary);
}

.nav-link.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(88, 70, 235, 0.35);
}

.nav-link.active svg {
  color: #ffffff;
}

/* Sidebar Info Card (Illustration) */
.sidebar-card-info {
  background: linear-gradient(180deg, #fbfaff 0%, #f4f1ff 100%);
  border: 1px solid #e9e4fd;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 24px;
  text-align: center;
  position: relative;
}

.sidebar-card-info .info-illu {
  width: 76px;
  height: 76px;
  margin: 0 auto 10px;
  display: block;
}

.sidebar-card-info h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.sidebar-card-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.sidebar-card-info .info-heart {
  color: var(--pink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-card-info .btn-help {
  background-color: var(--primary);
  color: white;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-card-info .btn-help:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 3px 10px rgba(88, 70, 235, 0.3);
}

/* ==========================================================
   MAIN CONTENT & TOPBAR
   ========================================================== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.3s ease;
}

/* Top Header */
.topbar {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(8px);
}

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

/* Hamburger Menu Button */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.hamburger-btn:hover {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #312e81;
}

.topbar-brand span {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Notification Bell */
.notification-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #4b5563;
  transition: var(--transition);
  flex-shrink: 0;
}

.notification-btn:hover {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background-color: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ==========================================================
   USER PROFILE & DROPDOWN MENU
   ========================================================== */
.user-profile-wrapper {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 30px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  user-select: none;
}

.user-profile-btn:hover,
.user-profile-btn.active {
  background-color: #f1f4fb;
  border-color: var(--border-color);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  border: 2px solid #e0e7ff;
}

.user-avatar.officer {
  background-color: #edeafe;
  color: #5846eb;
}

.user-avatar.patient {
  background-color: #fce7f3;
  color: #ec4899;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.profile-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.user-profile-btn.active .profile-chevron {
  transform: rotate(180deg);
}

/* Profile Dropdown Menu */
.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
  animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown.show {
  display: flex;
}

.dropdown-header-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid #f1f4f9;
  margin-bottom: 4px;
}

.dropdown-role-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
}

.dropdown-role-option:hover {
  background-color: #f8faff;
  border-color: #e2e8f0;
}

.dropdown-role-option.active {
  background-color: var(--primary-subtle);
  border-color: #dcd7fe;
}

.role-opt-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.role-opt-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.role-opt-avatar.officer { background-color: #edeafe; color: var(--primary); }
.role-opt-avatar.patient { background-color: #fce7f3; color: #ec4899; }

.role-opt-text h5 {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.role-opt-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.role-check-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  background-color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid #dcd7fe;
}

.dropdown-divider {
  height: 1px;
  background-color: #f1f4f9;
  margin: 4px 0;
}

.dropdown-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #4b5563;
  font-size: 0.82rem;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  text-align: left;
}

.dropdown-action-item:hover {
  background-color: #f8fafc;
  color: var(--primary);
}

/* Content Container */
.main-content {
  padding: 24px 28px 40px;
  flex: 1;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Views Navigation (SPA) */
.view-section {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.view-section.active {
  display: block;
}

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

/* Global Page Header in Content */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title-group h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.page-title-group p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-card);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  color: #4b5563;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.date-badge svg {
  color: var(--text-muted);
}

/* Global Breadcrumb */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.breadcrumb-nav a:hover {
  color: var(--primary);
}

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

.breadcrumb-nav .sep {
  color: var(--text-light);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-back:hover {
  background-color: #f8faff;
  border-color: #cbd5e1;
}

/* Global Footer */
.app-footer {
  text-align: center;
  padding: 20px 28px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-card);
  margin-top: auto;
}

/* ==========================================================
   TOAST NOTIFICATION
   ========================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background-color: #ffffff;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateX(0);
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

.toast-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.toast-success .toast-icon { color: var(--success); }
.toast-danger .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-content h5 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}
.toast-content p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================
   MODAL DIALOG
   ========================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-dialog {
  background-color: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.18);
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================
   COMPREHENSIVE RESPONSIVE DESIGN (ALL DEVICES)
   ========================================================== */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .hamburger-btn {
    display: flex;
  }

  .topbar {
    padding: 0 20px;
  }

  .main-content {
    padding: 20px 20px 36px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-brand span {
    display: none;
  }

  .user-info {
    display: none;
  }

  .user-profile-btn {
    padding: 3px;
  }

  .main-content {
    padding: 16px 14px 32px;
  }

  .page-header {
    margin-bottom: 18px;
  }

  .page-title-group h2 {
    font-size: 1.25rem;
  }

  .date-badge {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .toast {
    min-width: 100%;
  }

  .profile-dropdown {
    right: -8px;
    width: calc(100vw - 28px);
    max-width: 320px;
  }
}

@media (max-width: 480px) {
  .topbar-brand h2 {
    font-size: 1rem;
  }

  .logo-icon-wrapper {
    width: 34px;
    height: 34px;
  }

  .hamburger-btn {
    width: 36px;
    height: 36px;
  }

  .notification-btn {
    width: 36px;
    height: 36px;
  }

  .modal-dialog {
    margin: 10px;
  }

  .modal-body {
    padding: 16px;
  }
}
