/* ==========================================================================
   হিসাব খাতা - সিনিয়র বিজনেস ম্যানেজার (ডিজাইন সিস্টেম ও লেআউট)
   ========================================================================== */

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

:root {
  /* Color Palette */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #059669;
  --primary-light: #d1fae5;
  --primary-dark: #047857;
  
  --income: #10b981;
  --income-bg: #ecfdf5;
  --expense: #ef4444;
  --expense-bg: #fef2f2;
  --bank: #2563eb;
  --bank-bg: #eff6ff;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
  
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-family: 'Hind Siliguri', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --base-font-size: 16px;
  --nav-height: 68px;
  --header-height: 65px;
}

/* Senior Mode: Enhanced Contrast & Bigger Font */
body.senior-mode {
  --base-font-size: 16px;
  --text-main: #000000;
  --text-muted: #334155;
  --border-color: #cbd5e1;
}

body.senior-mode .btn {
  font-size: 0.92rem;
  font-weight: 600;
}

body.senior-mode .form-control {
  font-size: 1rem;
  font-weight: 500;
}

body.senior-mode .nav-item span {
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  white-space: nowrap;
}

body.senior-mode .stat-number {
  font-size: 1.7rem !important;
  font-weight: 800 !important;
}

/* Dark Mode Support (True Matte OLED / AMOLED Black) */
body.dark-mode {
  --bg-primary: #000000;
  --bg-surface: #0a0a0a;
  --bg-card: #121212;
  --bg-card-subtle: #181818;
  --text-main: #ffffff;
  --text-muted: #a1a1aa;
  --text-light: #71717a;
  --border-color: #222222;
  
  --primary-light: rgba(5, 150, 105, 0.2);
  --income: #34d399;
  --income-bg: rgba(16, 185, 129, 0.12);
  --expense: #f87171;
  --expense-bg: rgba(239, 68, 68, 0.12);
  --bank: #60a5fa;
  --bank-bg: rgba(59, 130, 246, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --purple: #a78bfa;
  --purple-bg: rgba(139, 92, 246, 0.12);
}

body.dark-mode.senior-mode {
  --text-main: #ffffff;
  --text-muted: #d4d4d8;
  --border-color: #333333;
}

/* Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  font-size: var(--base-font-size);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 50px);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Layout Wrapper */
.app-layout {
  display: block;
  min-height: 100vh;
  width: 100%;
}

/* Desktop Sidebar (Default Hidden on Mobile) */
.desktop-sidebar {
  display: none;
}

/* App Container */
.app-container {
  max-width: 650px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background-color: var(--bg-primary);
  padding-bottom: 20px;
}

/* ==========================================================================
   Desktop / PC Responsive View (@media min-width: 992px)
   ========================================================================== */
@media (min-width: 992px) {
  body {
    padding-bottom: 0;
  }

  .app-layout {
    display: flex;
    max-width: 1440px;
    margin: 0 auto;
    background-color: var(--bg-primary);
  }

  /* পিসি সাইডবার দৃশ্যমান ও স্টিকি */
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: 290px;
    min-width: 290px;
    height: 100vh;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 24px 18px;
    overflow-y: auto;
    z-index: 120;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.03);
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
  }

  .sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
  }

  .sidebar-brand-text h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
  }

  .sidebar-brand-text p {
    font-size: 0.88rem;
    color: var(--text-muted);
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
  }

  .sidebar-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    padding: 12px 14px !important;
    border-radius: var(--radius-md) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: var(--text-muted) !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    text-align: left !important;
  }

  .sidebar-item i {
    font-size: 1.4rem !important;
  }

  .sidebar-item:hover {
    background: var(--bg-card-subtle) !important;
    color: var(--text-main) !important;
  }

  .sidebar-item.active {
    background: var(--primary-light) !important;
    color: var(--primary-dark) !important;
    border-color: var(--primary) !important;
  }

  body.dark-mode .sidebar-item.active {
    background: rgba(5, 150, 105, 0.2) !important;
    color: #34d399 !important;
  }

  .sidebar-quick-action {
    margin: 20px 0 16px;
  }

  .sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
  }

  .sidebar-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
  }

  .sidebar-copyright {
    font-size: 0.78rem;
    color: var(--text-light);
    text-align: center;
  }

  /* পিসি ভিউতে মেইন কনটেইনারের বিস্তার */
  .app-container {
    flex: 1;
    max-width: none;
    margin: 0;
    padding: 0 30px 40px 30px;
    min-height: 100vh;
  }

  .app-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0 16px;
    margin-bottom: 16px;
  }

  .month-selector-bar {
    border-radius: var(--radius-md);
    margin-bottom: 24px;
  }

  /* পিসিতে ৪-কলামের স্ট্যাট গ্রিড */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
    margin-bottom: 24px !important;
  }

  .stat-card.full-width {
    grid-column: span 1 !important;
  }

  /* ভাটার ৬টি কার্ড ৩-কলাম x ২-সারি সুষম গ্রিড */
  .brick-stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* পিসিতে ড্যাশবোর্ড ২-কলাম স্প্লিট */
  .desktop-dashboard-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.3fr;
    gap: 24px;
    align-items: start;
  }

  /* পিসিতে কার্ড লিস্ট গ্রিড ভিউ */
  #shopCardsList, #medicalCardsList, #staffCardsList, #bankAccountsList, #otherExpensesList, #brickSalesList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
  }

  /* পিসিতে মোবাইল বটম ন্যাভ ও ফ্যাব বাটন হাইড থাকবে */
  .bottom-nav, .fab-container {
    display: none !important;
  }
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #059669, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
  flex-shrink: 0;
}

.header-title-box {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.header-title-box h1 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title-box p {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hide-on-mobile {
  display: flex;
}

@media (max-width: 600px) {
  .app-header {
    padding: 8px 12px;
    gap: 8px;
  }

  .header-brand {
    gap: 6px;
  }

  .header-title-box h1 {
    font-size: 1.02rem;
  }

  .header-title-box p {
    font-size: 0.74rem;
  }

  .header-actions {
    gap: 5px;
  }

  .hide-on-mobile {
    display: none !important;
  }

  .cloud-sync-pill {
    width: 34px !important;
    height: 34px !important;
    font-size: 1.15rem !important;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }

  .header-avatar {
    width: 34px;
    height: 34px;
    font-size: 1.5rem;
  }

  .header-back-btn {
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    flex-shrink: 0;
  }
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid #a7f3d0;
  background: #f0fdf4;
  color: #059669;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  border-color: #059669;
  color: #047857;
  background: #d1fae5;
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.active {
  background: #d1fae5;
  color: #047857;
  border-color: #059669;
}

.icon-btn.voice-btn {
  background: #059669 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.35);
}

body.dark-mode .icon-btn {
  background: rgba(5, 150, 105, 0.15) !important;
  border: 1px solid #059669 !important;
  color: #34d399 !important;
}

body.dark-mode .icon-btn:hover {
  background: rgba(5, 150, 105, 0.3) !important;
  border-color: #10b981 !important;
  color: #6ee7b7 !important;
}

body.dark-mode .icon-btn.active {
  background: rgba(5, 150, 105, 0.25) !important;
  color: #34d399 !important;
  border-color: #059669 !important;
}

body.dark-mode .icon-btn.voice-btn {
  background: #10b981 !important;
  color: #000000 !important;
  border-color: #10b981 !important;
}

/* নোটিফিকেশন বাটন ও ব্যাজ */
.notif-btn {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
  animation: pulse-badge 2s infinite ease-in-out;
}

body.dark-mode .notif-badge {
  border-color: #0a0a0a;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Cloud Sync Status Indicator Pill */
.cloud-sync-pill {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  font-size: 1.3rem;
  border: 1px solid rgba(16, 185, 129, 0.25);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.cloud-sync-pill.syncing {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
  animation: spinSlow 2s linear infinite;
}

.cloud-sync-pill.offline {
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
  border-color: rgba(100, 116, 139, 0.25);
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Month Filter Selector */
.month-selector-bar {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.month-nav-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.current-month-display {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main Content Area */
.main-content {
  padding: 8px 16px 20px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
  display: block;
}

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

/* Bottom Navigation Bar (Native App Style with Safe Area Support) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  max-width: 650px;
  margin: 0 auto;
  padding-left: 6px;
  padding-right: 6px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
  border-radius: var(--radius-md);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
  gap: 3px;
  position: relative;
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item i {
  font-size: 1.45rem;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active i {
  transform: translateY(-2px) scale(1.12);
}

.nav-item span {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.2px;
  line-height: 1.1;
  text-align: center;
  display: block;
}

body.senior-mode .nav-item span {
  font-size: 0.84rem !important;
  font-weight: 700 !important;
}

@media (max-width: 380px) {
  .nav-item span {
    font-size: 0.72rem !important;
  }
  .nav-item i {
    font-size: 1.3rem;
  }
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
}

body.dark-mode .nav-item.active {
  background: rgba(5, 150, 105, 0.2);
  color: #34d399;
}

.nav-item.active i {
  transform: translateY(-2px);
}

/* Floating Action Button (+ নতুন এন্ট্রি) */
.fab-container {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 20px;
  z-index: 90;
}

.fab-btn {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  border: none;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-btn:hover {
  transform: scale(1.08) rotate(90deg);
}

.fab-btn:active {
  transform: scale(0.95);
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 12px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--primary);
}

/* Senior Friendly Voice Announcement Banner */
.voice-assistant-banner,
.voice-banner {
  background: linear-gradient(135deg, #065f46, #047857) !important;
  color: white !important;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(4, 120, 87, 0.25);
  cursor: pointer;
  border: 1px solid rgba(52, 211, 153, 0.35);
  transition: all 0.25s ease;
}

.voice-assistant-banner:hover,
.voice-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(4, 120, 87, 0.35);
  background: linear-gradient(135deg, #047857, #059669) !important;
}

.voice-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.voice-wave-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
  animation: pulse-wave 2s infinite ease-in-out;
}

@keyframes pulse-wave {
  0%, 100% { transform: scale(1); background: rgba(255, 255, 255, 0.22); }
  50% { transform: scale(1.08); background: rgba(255, 255, 255, 0.38); }
}

.voice-banner-text h3,
.voice-banner-text h4 {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: #ffffff;
}

.voice-banner-text p {
  font-size: 0.84rem;
  color: #d1fae5;
  line-height: 1.2;
}

.voice-play-pill {
  flex-shrink: 0;
  background: #ffffff !important;
  color: #065f46 !important;
  font-weight: 700 !important;
  border-radius: var(--radius-full) !important;
  padding: 8px 14px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.voice-play-pill:hover {
  transform: scale(1.04);
}

.voice-btn {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5) !important;
  color: #059669 !important;
  border: 1px solid #10b981 !important;
}

body.dark-mode .voice-assistant-banner,
body.dark-mode .voice-banner {
  background: linear-gradient(135deg, #043b2c, #02261c) !important;
  border-color: #0d5f3f;
}

body.dark-mode .voice-play-pill {
  background: #34d399 !important;
  color: #000000 !important;
}

body.dark-mode .voice-btn {
  background: #062b1e !important;
  color: #34d399 !important;
  border-color: #059669 !important;
}

/* Print Styles for Receipts */
@media print {
  body {
    background: white !important;
    color: black !important;
    padding: 0 !important;
  }
  .app-header, .bottom-nav, .fab-container, .month-selector-bar, .no-print {
    display: none !important;
  }
  .receipt-print-area {
    display: block !important;
    padding: 20px;
    border: 2px solid #000;
  }
}
