/* resize.css */
/* Load after styles.css */

:root {
  --sidebar-width-desktop: 20%;
  --gutter: 1.25rem;
  --card-gap: 2rem;
  --feed-max-width: 650px;
  --title-base: 1.5rem;
}

/* 1) General improvements for all breakpoints */
.chart-wrapper,
#lineChartWrapper,
#incomeLineChart,
#expenseLineChart,
#financialChart {
  max-width: 100%;
}

/* 2) Large laptops (<= 1440px) */
@media (max-width: 1440px) {
  .website-title {
    font-size: 1.2rem;
  }
  .info-card {
    gap: 2rem;
  }
  .card-value {
    font-size: 1.75rem;
  }
  .chart-wrapper {
  position: relative;
  width: 95%;
  max-width: 550px;
  max-height: 75%;
  aspect-ratio: 1;
  flex-shrink: 1;
}

.health-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-radius: 15px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.health-message svg { width: 18px; height: 18px; flex-shrink: 0; }

}

/* 3) Standard laptops / small desktops (<= 1200px) */
@media (max-width: 1200px) {
  .sidebar-container {
    flex: 0 0 16%;
    padding-right: 3.5rem;
  }
  .website-title {
    font-size: calc(var(--title-base) * 0.9);
    left: 1.25rem;
  }
  #dashboard .top-row {
    gap: 1.25rem;
  }
  .info-card {
    height: 135px;
    padding: 1.25rem;
  }

}

/* ================================
   TABLET LANDSCAPE (≈1024–1180 wide)
   Permanent left sidebar
   ================================ */
@media (min-width: 1024px) and (max-width: 1180px) and (orientation: landscape) {
  :root {
    --gutter: 1rem;
    --kpi-gap: 0.75rem;
  }

  /* Sidebar + content sizing */
  .app-container { display: flex; gap: 0.75rem; height: 100vh; }
  .sidebar-container {
    flex: 0 0 220px;
    max-width: 220px;
    min-width: 220px;
  }
  .content-container {
    flex: 1 1 auto;
    max-width: 920px;            /* keep column tight so layout looks balanced */
    margin: 0 auto;
    padding: 0 var(--gutter);
  }

  /* Top bar: smaller title and icons */
  .topbar {
    position: sticky; top: 0; z-index: 10;
    background: #fff;
    padding: 0.55rem var(--gutter) 0.4rem;
    border-bottom: 1px solid #eee;
  }
  .website-title {
    font-size: 0.98rem;          /* smaller title */
    line-height: 1.2;
    margin-bottom: 0.35rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar .nav-links { display: flex; gap: 0.6rem; flex-wrap: wrap; }
  .topbar .nav-links a svg { width: 15px; height: 15px; }

  /* KPI: FORCE 3 CARDS IN ONE CENTERED ROW */
  #dashboard .top-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: var(--kpi-gap);
    flex-wrap: nowrap;            /* single row */
    max-width: 100%;             /* align to content width */
    margin: 0 auto;
  }
  .info-card {
    flex: 0 0 290px;              /* 290 * 3 + gaps fits 920px */
    max-width: 240px;
    height: 100px;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
  }
  .card-icon { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
  .card-title { font-size: 0.92rem; }
  .card-value { font-size: 1.18rem; }

  /* Chart first, trimmed height */
  .section-block { margin-top: 0.75rem; }
  .chart-wrapper {
    max-width: 520px;
    width: 100%;
    margin: 0.5rem auto 0.6rem;
  }
  #financialChart { width: 100%; height: 260px; }
  #incomeLineChart, #expenseLineChart { width: 100%; height: 255px; }

  /* Transaction feed compact */
  .transaction-feed,
  #incomeTransactionFeed,
  #expenseTransactionFeed {
    max-width: 560px;
    width: 100%;
    margin: 0.4rem auto 0.9rem;
  }
  .transaction-card {
    padding: 0.55rem 0.75rem;
    border: none;
    gap: 0.5rem;
    width: 350px;
  }
  .transaction-emoji { width: 2rem; height: 2rem; font-size: 1rem; }
  .transaction-title { font-size: 0.7rem; }
  .transaction-date { font-size: 0.6rem; opacity: 0.8; }
  .transaction-amount { font-size: 0.5rem; height: 30px; }

  .transaction-card svg {
    height: 14px;
  }

  /* No horizontal overflow from inner blocks */
  .view, .section-block, .chart-wrapper, .transaction-feed { overflow-x: hidden; }
}

/* Optional: shorter landscape height (e.g., 1080×810) */
@media (max-height: 820px) and (orientation: landscape) {
  #financialChart { height: 250px; }
  #incomeLineChart, #expenseLineChart { height: 240px; }
  .info-card { height: 96px; }
}


/* Optional: short landscape heights (~<= 820px) */
@media (max-height: 820px) and (orientation: landscape) {
  #financialChart { height: 280px; }
  #incomeLineChart, #expenseLineChart { height: 260px; }
  .info-card { height: 120px; }
}


/* Optional height guard for short landscape heights (~810px or less) */
@media (max-height: 820px) and (orientation: landscape) {
  #financialChart { height: 280px; }
  #incomeLineChart, #expenseLineChart { height: 260px; }
  .info-card { height: 120px; }
}


/* 5) Tablets portrait (iPad vertical, large phones, <= 834px) */
@media (max-width: 834px) {
  /* Stack layout: sidebar turns into a top bar */
  .app-container {
    display: flex;
    flex-direction: column;
    height: auto;
  }

  .sidebar-container {
    position: sticky;
    top: 0;
    z-index: 10;
    flex: 0 0 auto;
    height: 64px;
    padding: 0 var(--gutter);
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    justify-content: space-between;
  }

  .website-title {
    position: static;
    font-size: 1.1rem;
    margin-left: 0.25rem;
  }

  .nav-links {
    flex-direction: row;
    gap: 1rem;
  }

  .nav-links li a {
    font-size: 1rem;
  }

  .content-container {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem;
  }

  /* Views become vertical stacks */
  .view.active {
    display: flex;
  }

  /* Prioritize top content: charts/forms first, then feed last */
  .top-row {
    order: 1;
    flex: 0 0 auto;
  }
  .bottom-area {
    order: 2;
    flex-direction: column;
  }

  .bottom-left,
  .bottom-right {
    width: 100%;
    border-right: none;
    padding: 0.75rem 0;
    padding-left: 0 !important;
  }

  .bottom-right {
    order: 3;
  }

  /* Keep everything centered and fluid */
  .chart-wrapper,
  .transaction-feed {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
  }

  /* Smaller info cards to fit two per row if needed, else stack */
  #dashboard .top-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }
  .info-card {
    flex: 0 1 46%;
    min-width: 260px;
    height: 120px;
  }
}

/* 6) Phones large (<= 768px) */
@media (max-width: 768px) {
  .website-title {
    font-size: 1rem;
  }

  .nav-links li a {
    font-size: 0.95rem;
  }

  /* Stack cards single column */
  .info-card {
    flex: 1 1 100%;
    min-width: auto;
    height: auto;
    padding: 1rem;
  }
  .card-value {
    font-size: 1.4rem;
  }

  /* Charts: full width, maintain square where possible */
  .chart-wrapper {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
  }
  #incomeLineChart,
  #expenseLineChart {
    width: 100% !important;
    height: 260px !important;
  }

  /* Make forms more prominent than feeds */
  .bottom-area {
    display: flex;
    flex-direction: column;
  }
  .bottom-left { order: 1; }
  .bottom-right { order: 2; }

  /* Feed last, tighter spacing */
  .transaction-feed {
    order: 3;
    gap: 0.5rem;
    padding: 0 0.5rem;
  }
  .transaction-card {
    max-width: 480px;
    padding: 0.75rem;
  }
  .transaction-emoji { font-size: 1.25rem; width: 2.5rem; height: 2.5rem; }
  .transaction-amount { font-size: 0.8rem; height: 34px; }
}

/* 7) Phones medium (<= 640px) */
@media (max-width: 640px) {
  .website-title {
    font-size: 0.95rem;
  }

  .nav-links {
    gap: 0.75rem;
  }

  .chart-wrapper {
    max-width: 420px;
  }

  .form-header h3,
  .feed-header h3,
  .chart-header h3,
  .section-header-simple h3 {
    font-size: 1.05rem;
  }

  .btn-add-transaction {
    width: 100%;
  }
}

/* 8) Phones small (<= 480px) */
@media (max-width: 480px) {
  /* Keep UI clean and centered */
  .website-title {
    font-size: 0.7rem;
    padding-right: 10px;
  }

  .nav-links li a {
    font-size: 0.7rem;
    gap: 0.1rem;
  }

  .nav-links li a svg {
    width: 15px;
  }

  .app-container {
    margin: 0.5rem;
  }

  .content-container {
    padding: 0.5rem;
  }

  /* Reduce card heights/spacing */
  .info-card {
    padding: 0.75rem;
    gap: 1rem;
  }
  .card-icon {
    width: 3rem;
    height: 3rem;
  }
  .card-value {
    font-size: 1.25rem;
  }

  /* Charts scale down further */
  .chart-wrapper {
    max-width: 360px;
  }
  #incomeLineChart,
  #expenseLineChart {
    height: 220px !important;
  }

  /* Feed compacts */
  .transaction-card {
    max-width: 360px;
    gap: 0.75rem;
  }
  .transaction-title { font-size: 0.95rem; }
  .transaction-date { font-size: 0.8rem; }
}

/* 9) Very small devices (<= 360px) */
@media (max-width: 360px) {
  .website-title { font-size: 0.85rem; }
  .nav-links li a { font-size: 0.85rem; }
  .chart-wrapper { max-width: 300px; }
  .transaction-card { max-width: 300px; }
}
