/* ==========================================================================
   CRETA REPORT - SIDEBAR & SUB-NAV RESPONSIVE STYLESHEET
   ========================================================================== */

:root {
  --primary-color: #1877f2;
  --primary-hover: #166fe5;
  --primary-light: #e7f3ff;
  --sidebar-bg: #1e293b;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-text: #94a3b8;
  --sidebar-active-text: #ffffff;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --sidebar-width: 250px;
  --topbar-height: 60px;
}

body {
  background-color: var(--bg-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* APP WRAPPER */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* SIDEBAR (CỘT TRÁI CHỨA NGHIỆP VỤ CHÍNH) */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.5px;
}
.sidebar-brand:hover {
  color: #ffffff;
  text-decoration: none;
}
.sidebar-brand-badge {
  font-size: 10px;
  background: var(--primary-color);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  list-style: none;
  padding: 12px 10px;
  margin: 0;
  flex: 1;
}

.sidebar-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  padding: 12px 12px 6px;
}

.sidebar-item {
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.15s ease;
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active-text);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--primary-color);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.35);
}

.sidebar-icon {
  font-size: 1.15rem;
  width: 26px;
  text-align: center;
  margin-right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-dropdown-header {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-sidebar-submenu-toggle {
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-sidebar-submenu-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-arrow {
  margin-left: auto;
  font-size: 0.72rem;
  transition: transform 0.2s ease;
}

.sidebar-item.open .sidebar-arrow {
  transform: rotate(90deg);
}

.sidebar-submenu {
  list-style: none;
  padding: 4px 0 4px 34px;
  margin: 0;
  display: none;
}

.sidebar-item.open .sidebar-submenu {
  display: block;
}

.sidebar-sublink {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.sidebar-sublink:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}

.sidebar-sublink.active {
  color: #ffffff;
  background: rgba(24, 119, 242, 0.25);
  font-weight: 600;
  border-left: 3px solid var(--primary-color);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  color: #64748b;
  text-align: center;
}

/* MAIN LAYOUT (BÊN PHẢI SIDEBAR) */
.app-main-layout {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

/* TOPBAR */
.app-topbar {
  height: var(--topbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

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

.btn-sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-sidebar-toggle:hover {
  background: #f1f5f9;
}

.topbar-title-wrap {
  display: flex;
  flex-direction: column;
}
.topbar-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  line-height: 1.2;
}
.topbar-breadcrumbs {
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

/* SUB-NAVIGATION (MENU PHỤ CỦA TỪNG NGHIỆP VỤ) */
.app-subnav {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-subnav::-webkit-scrollbar {
  display: none;
}

.subnav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  margin-right: 8px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  background: #f1f5f9;
  transition: all 0.15s ease;
}

.subnav-link:hover {
  background: #e2e8f0;
  color: #0f172a;
  text-decoration: none;
}

.subnav-link.active {
  background: var(--primary-color);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.25);
}

/* CONTENT BODY */
.app-content-body {
  flex: 1;
  padding: 20px;
}

/* CARDS & COMPONENTS */
.app-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  margin-bottom: 20px;
  padding: 22px;
}

.desktop-table-view {
  display: block;
}

.mobile-card-view {
  display: none;
}

/* OVERLAY FOR MOBILE SIDEBAR */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1035;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
  display: block;
}

/* MOBILE RESPONSIVE (< 992px) */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .app-sidebar.show-mobile {
    transform: translateX(0);
  }

  .app-main-layout {
    margin-left: 0 !important;
  }

  .app-content-body {
    padding: 14px 10px;
  }

  .desktop-table-view {
    display: none !important;
  }

  .mobile-card-view {
    display: block !important;
  }

  .invoice-mobile-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    padding: 14px 16px;
    margin-bottom: 12px;
  }

  .invoice-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }

  .invoice-mobile-code {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
  }

  .invoice-mobile-customer {
    font-size: 0.95rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 6px;
  }

  .invoice-mobile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
  }
}
