﻿/* ================= GLOBAL RESET ================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  background: #f5f7fb;
}

/* ================= TOPBAR ================= */
/* Topbar */
.topbar {
  height: 50px;
  background: #1f2235;
  color: #fff;
  position: fixed; /* fixed at top */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100; /* above everything */
  display: flex;
  align-items: center;
  padding: 0 15px;
}

.menu-toggle {
  font-size: 22px;
  cursor: pointer;
  color: #fff;
}

/* ================= SIDEBAR ================= */
/* Sidebar */
/* ================= SIDEBAR ================= */
.sidebar {
  width: 240px;
  background: #1f2235;
  position: fixed;
  top: 50px; /* below topbar */
  left: 0;
  height: calc(100% - 50px); /* full height minus topbar */
  padding: 10px;
  transition: all 0.3s ease;
  z-index: 1050; /* below topbar */
  overflow-y: auto;
}

/* Sidebar links */
.sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  color: #cfd3ff;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 6px;
}

.sidebar a:hover,
.sidebar a.active {
  background: #0d6efd;
  color: #fff;
}

/* Submenu */
.sidebar-item {
  display: flex;
  flex-direction: column;
}

.sidebar-item > a {
  cursor: pointer;
}

.submenu {
  display: none;
  flex-direction: column;
  padding-left: 42px;
}

.submenu a {
  font-size: 14px;
  padding: 6px 0;
  color: #bfc4ff;
}

.sidebar-item.open .submenu {
  display: flex;
}

.arrow {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.sidebar-item.open .arrow {
  transform: rotate(90deg);
}

/* ================= CONTENT AREA ================= */
.content-area {
  margin-top: 50px; /* space for fixed topbar */
  margin-left: 240px; /* space for sidebar */
  width: calc(100% - 240px);
  padding: 15px;
  transition: all 0.3s ease;
}

/* Collapsed sidebar */
.sidebar.collapsed {
  width: 60px;
}

.content-area.collapsed {
  margin-left: 60px;
  width: calc(100% - 60px);
}
/* ================= SIDEBAR COLLAPSE FIX ================= */

/* Hide the text when sidebar collapsed */
.sidebar.collapsed a span {
  display: none;
}

/* Align arrow vertically with icon */
.sidebar.collapsed a {
  justify-content: center; /* center icon + arrow horizontally */
  position: relative;      /* for proper arrow placement */
}

.sidebar.collapsed .arrow {
display:none;
}

/* Keep submenu hidden completely on collapsed */
.sidebar.collapsed .submenu {
  display: none !important;
  padding-left: 0;
}

/* ================= MOBILE ================= */
@media (max-width: 991px) {

  /* Sidebar hidden by default on mobile */
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  /* Disable collapsed on mobile */
  .sidebar.collapsed {
    width: 240px;
  }

  /* Content fills full width */
  .content-area,
  .content-area.collapsed {
    margin-left: 0 !important;
    width: 100% !important;
  }
}


/* ================= CARDS & UI ================= */
.card {
  border-radius: 10px;
  margin-bottom: 10px;
}

.chart-placeholder {
  height: 200px;
  background: #f5f5f5;
  border-radius: 6px;
}

.side-card {
  background: #fff;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  margin-bottom: 10px;
}

/* ================= TABLE SCROLL ================= */
.table-scroll {
  max-height: 250px;
  overflow-y: auto;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

/* ================= SMALL UI ================= */
.logo-text {
  font-size: 22px;
  font-weight: 700;
  color: #22a7f0;
}

.erp-badge {
  background: #fff;
  color: #111;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.quick-action {
  color: #cfd3ff;
  cursor: pointer;
}

.top-info {
  color: #d6d8ff;
  font-size: 13px;
}

.notify-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background: #ff3b3b;
  color: #fff;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 50%;
}

.financial-year {
  background: #fff;
  color: #111;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: #22a7f0;
  color: #fff;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ================= MOBILE CONTENT STACK ================= */
@media (max-width: 768px) {

  .row {
    display: flex;
    flex-direction: column;
  }

  .row > div {
    width: 100% !important;
  }

  table {
    font-size: 12px;
  }

  .status-card {
    margin-bottom: 10px;
  }
}

/* ================= TOPBAR RESPONSIVE ================= */

/* Small screens (phones) */
@media (max-width: 768px) {
  .topbar {
    height: auto; /* allow wrapping */
    padding: 5px 10px;
    display: flex;
    flex-wrap: wrap; /* wrap elements if needed */
    align-items: center;
  }

  .logo-text {
    font-size: 18px;
  }

  .erp-badge,
  .financial-year {
    font-size: 10px;
    padding: 2px 5px;
  }

  .top-info {
    font-size: 11px;
  }

  .quick-action {
    font-size: 12px;
    margin-left: 5px;
  }

  /* Sidebar should start exactly at topbar */
  .sidebar {
    top: 0; /* no gap */
    height: 100%; /* full screen height */
    width: 200px;
    padding-top:40px;
  }
}

/* Extra small screens (small phones) */
@media (max-width: 480px) {
  .logo-text {
    font-size: 16px;
  }

  .erp-badge,
  .financial-year {
    font-size: 9px;
    padding: 2px 4px;
  }

  .top-info {
    font-size: 10px;
  }

  .quick-action {
    font-size: 11px;
    margin-left: 4px;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  /* Sidebar no gap */
  .sidebar {
    top: 0; /* start from very top */
    height: 100%;
    width: 220px;
  }
}
}
.submenu {
    display: none;
    padding-left: 20px;
}
/* Small screens (phones/tablets) */
@media (max-width: 768px) {
  .card,
  .side-card {
    padding: 12px;
    margin-bottom: 8px;
  }

  .chart-placeholder {
    min-height: 180px;
    margin-bottom: 8px;
  }

  .card-text,
  .side-card-text {
    font-size: 13px;
    margin-top: 6px;
  }
}

/* Extra small screens (small phones) */
@media (max-width: 480px) {
  .card,
  .side-card {
    padding: 10px;
    margin-bottom: 6px;
  }

  .chart-placeholder {
    min-height: 150px;
    margin-bottom: 6px;
  }

  .card-text,
  .side-card-text {
    font-size: 12px;
    margin-top: 4px;
  }
}
@media (max-width: 576px) {

  /* Enable horizontal scroll */
  .category-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent column shrink */
  .category-table table {
    min-width: 520px; /* 🔥 last column visible */
    white-space: nowrap;
    font-size: 12px;
  }

  /* Reduce padding for mobile */
  .category-table th,
  .category-table td {
    padding: 6px 8px;
    text-align: center;
    vertical-align: middle;
  }

}
@media (max-width: 576px) {

  #salesPurchaseChart {
    width: 100% !important;
    height: 260px !important;
  }

}
@media (max-width: 576px) {

  #transactionChart {
    width: 100% !important;
    height: 280px !important;
  }

  /* Header stack */
  .transaction-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }

}
/* Make header stack on small screens */
/* Responsive header controls */
@media (max-width: 576px) {
  /* Keep heading on top */
  .d-flex.justify-content-between.align-items-center.mb-3 {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem;
  }

  /* Controls go to next line and wrap */
  .d-flex.gap-2 {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    width: 100%;
  }

  /* Make select, input, buttons adjust nicely */
  .d-flex.gap-2 select.form-select,
  .d-flex.gap-2 input.form-control,
  .d-flex.gap-2 button {
    flex: 1 1 auto;
    width: auto; /* allow flexible width */
    min-width: 120px; /* optional minimum width */
  }
}
.submenu {
  display: none;
  padding-left: 28px;
}

.sidebar-item.open .submenu {
  display: block;
}

.arrow {
  transition: transform 0.3s ease;
}

.sidebar-item.open .arrow {
  transform: rotate(90deg);
}

/* Better UX */
.sidebar-link,
.submenu-toggle {
  cursor: pointer;
}
