/* =========================================================
   PREMIUM NAVBAR (MOBILE-FIXED WITH COLLAPSIBLE SEARCH)
   File: assets/css/navbar.css
   ========================================================= */

.navbar,
#navbar {
  min-height: 76px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid #e5e7eb;
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ==================== ROOT LAYOUT ==================== */
.top-navbar {
  min-height: 76px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.navbar-left,
.navbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.navbar-left {
  justify-content: flex-start;
  flex: 1;
}

.navbar-right {
  justify-content: flex-end;
}

/* ==================== TITLE ==================== */
.nav-title {
  font-size: 18px;
  font-weight: 900;
  color: #0f172a;
  white-space: nowrap;
}

/* ==================== ICON BUTTONS ==================== */
.nav-icon-btn {
  width: 46px;
  height: 46px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 15px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  font-size: 18px;
  color: #334155;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  transition: 0.2s ease;
  flex: 0 0 auto;
}

.nav-icon-btn:hover {
  transform: translateY(-1px);
  background: #f8fafc;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

/* ==================== NOTIFICATION DOT ==================== */
.nav-dot,
.badge-dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid #ffffff;
}

/* ==================== SEARCH ==================== */
.navbar-search {
  width: min(460px, 42vw);
  height: 48px;
  border-radius: 15px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: #64748b;
  transition: 0.2s ease;
}

.navbar-search:focus-within {
  background: #ffffff;
  border-color: #a7f3d0;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.navbar-search-icon {
  font-size: 22px;
  color: #64748b;
  cursor: pointer;
}

.navbar-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  height: 100%;
  color: #0f172a;
  font-size: 14px;
  min-width: 0;
}

.navbar-search input::placeholder {
  color: #94a3b8;
}

.navbar-search kbd {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  border-radius: 8px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ==================== USER PROFILE ==================== */
.navbar-user-wrap {
  position: relative;
}

.navbar-user-btn {
  height: 52px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 18px;
  transition: 0.2s ease;
}

.navbar-user-btn:hover {
  background: #f8fafc;
}

.navbar-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #2563eb);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
}

.navbar-user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.navbar-user-text strong {
  font-size: 14px;
  color: #0f172a;
}

.navbar-user-text span {
  font-size: 12px;
  color: #64748b;
}

.navbar-chevron {
  color: #64748b;
  font-size: 18px;
}

/* ==================== USER DROPDOWN ==================== */
.navbar-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 190px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  padding: 8px;
  display: none;
  z-index: 100;
}

.navbar-user-menu.open {
  display: block;
}

.navbar-user-menu button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 11px;
  color: #334155;
  font-weight: 700;
  cursor: pointer;
}

.navbar-user-menu button:hover {
  background: #f8fafc;
}

.navbar-user-menu button.danger {
  color: #dc2626;
}

/* ==================== NOTIFICATION PANEL ==================== */
.notification-panel {
  position: absolute;
  top: 70px;
  right: 16px;
  width: min(420px, calc(100vw - 32px));
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  overflow: hidden;
  z-index: 90;
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 800;
}

.notification-list {
  max-height: 420px;
  overflow: auto;
}

.notification-item {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.notification-item.unread {
  background: #eff6ff;
}

.notification-item-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.notification-item-time {
  color: #64748b;
  font-size: 12px;
  margin-top: 4px;
}

/* ==================== MOBILE RESPONSIVE (COLLAPSIBLE SEARCH) ==================== */

/* Tablet and medium screens */
@media (max-width: 1100px) {
  .nav-title {
    display: none;
  }

  .navbar-search {
    width: min(420px, 50vw);
  }
}

/* Mobile screens */
@media (max-width: 768px) {
  .top-navbar {
    padding: 8px 12px;
    gap: 12px;
  }

  /* Hide title on mobile */
  .nav-title {
    display: none;
  }

  /* Hide user text and chevron on mobile */
  .navbar-user-text,
  .navbar-chevron {
    display: none;
  }

  /* Make icon buttons slightly smaller */
  .nav-icon-btn {
    width: 40px;
    height: 40px;
  }

  .nav-icon-btn i {
    font-size: 16px;
  }

  /* Adjust avatar size */
  .navbar-avatar {
    width: 40px;
    height: 40px;
  }

  /* User button minimal padding */
  .navbar-user-btn {
    padding: 4px;
    gap: 0;
  }

  /* COLLAPSIBLE SEARCH STYLES */
  .navbar-search {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
  }

  /* Expanded search state */
  .navbar-search.expanded {
    width: calc(100vw - 24px);
    max-width: 100%;
    padding: 0 12px;
    justify-content: flex-start;
    background: #ffffff;
    position: absolute;
    left: 12px;
    right: 12px;
    top: 8px;
    z-index: 60;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  /* Hide input and kbd initially */
  .navbar-search input,
  .navbar-search kbd {
    display: none;
  }

  /* Show input and kbd when expanded */
  .navbar-search.expanded input {
    display: block;
    flex: 1;
  }

  .navbar-search.expanded kbd {
    display: block;
  }

  /* Keep search icon visible and clickable */
  .navbar-search-icon {
    font-size: 18px;
  }

  .navbar-search.expanded .navbar-search-icon {
    font-size: 18px;
  }

  /* Overlay for when search is expanded */
  .search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
    display: none;
  }

  .search-overlay.active {
    display: block;
  }

  /* Adjust navbar z-index when search expanded */
  .navbar.expanded-search {
    z-index: 61;
  }

  /* Hide other icons when search expanded? No - keep them visible but behind overlay */
  /* The overlay will capture clicks outside search */
}

/* Very small screens */
@media (max-width: 480px) {
  .top-navbar {
    padding: 6px 10px;
    gap: 8px;
  }

  .nav-icon-btn {
    width: 36px;
    height: 36px;
  }

  .nav-icon-btn i {
    font-size: 14px;
  }

  .navbar-avatar {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }

  .navbar-search {
    width: 36px;
    height: 36px;
  }

  .navbar-search.expanded {
    width: calc(100vw - 20px);
    left: 10px;
    right: 10px;
    top: 6px;
  }
}

/* =========================================================
   FONT AWESOME NAVBAR ICON POLISH
   ========================================================= */

.nav-icon-btn i,
.navbar-search-icon i,
.navbar-avatar i,
.navbar-chevron i,
.navbar-user-menu i {
  line-height: 1;
  display: block;
}

.nav-icon-btn i {
  font-size: 17px;
}

.navbar-search-icon i {
  font-size: 18px;
}

.navbar-avatar i {
  font-size: 15px;
}

.navbar-chevron i {
  font-size: 11px;
}

.navbar-user-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-user-menu i {
  width: 16px;
  font-size: 14px;
}
/* =========================================================
   DASHBOARD ONLY NAVBAR - FINAL LAYOUT FIX
   File: assets/css/navbar.css

   Purpose:
   - Navbar visible only on dashboard
   - No blank top area on Sales/Purchase/Stock/Settings
   - Fixes .main-section grid reserved navbar row
   ========================================================= */

/* ==================== NORMAL DASHBOARD NAVBAR WRAPPER ==================== */
.dashboard-navbar-section {
  display: block;
  grid-row: 1;
}

/* ==================== ROUTER CONTENT POSITION ==================== */
.main-section > .app-content {
  grid-row: 2;
}

/* ==================== HIDDEN NAVBAR STATE ==================== */
.dashboard-navbar-section.is-hidden {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}

/* ==================== NON-DASHBOARD GRID FIX ==================== */
body.navbar-page-hidden .main-section {
  grid-template-rows: 1fr !important;
}

/* Move app content to first row when navbar is hidden */
body.navbar-page-hidden .main-section > .app-content {
  grid-row: 1 !important;
  padding-top: 24px !important;
  margin-top: 0 !important;
}

/* Ensure hidden navbar itself never reserves space */
body.navbar-page-hidden #navbar,
body.navbar-page-hidden .navbar {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}


/* ==================== DASHBOARD ONLY FINAL OVERRIDES ==================== */
.nav-title-empty { display:none !important; }
.notification-panel.hidden { display:none !important; }
.notification-item.due-invoice { background:#fff7ed; border-left:4px solid #f97316; }


/* =========================================================
   DASHBOARD-ONLY NAVBAR FINAL FIX
   ========================================================= */
body.navbar-page-hidden .dashboard-navbar-section {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
}

body.navbar-page-hidden .main-section {
  grid-template-rows: 1fr !important;
}

body.navbar-page-hidden .main-section > .app-content {
  grid-row: 1 !important;
  padding-top: 24px !important;
  margin-top: 0 !important;
}

body.navbar-page-hidden #navbar,
body.navbar-page-hidden .navbar {
  display: none !important;
}

/* =========================================================
   CLEAN ROUTE NAVBAR VISIBILITY
   Navbar stays only on /dashboard; other modules get full space.
   ========================================================= */
.dashboard-navbar-section.is-hidden,
body.navbar-page-hidden .dashboard-navbar-section,
body.route-no-navbar .dashboard-navbar-section {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}

body.navbar-page-hidden #navbar,
body.route-no-navbar #navbar {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
}

body.navbar-page-hidden .app-content,
body.route-no-navbar .app-content {
  padding-top: 24px !important;
}
