/* === Base & Viewport === */
html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 15px;
  }
}

@media (min-width: 992px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* === App Wrapper (prevents overflow) === */
.app-wrapper {
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

/* === Sidebar === */
:root {
  --sidebar-accent: #6366f1;
  --sidebar-accent-bg: rgba(99, 102, 241, 0.08);
  --sidebar-accent-hover: #4f46e5;
}

.sidebar {
  width: 280px;
  min-width: 280px;
  min-height: 100vh;
  max-height: 100vh;
  background: #fafafa;
  border-right: 1px solid #e5e7eb;
  transition: width 0.2s ease, min-width 0.2s ease;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 991.98px) {
  .sidebar {
    width: 260px;
    min-width: 260px;
  }
}

.sidebar.collapsed {
  width: 64px;
  min-width: 64px;
}

.sidebar.collapsed .nav-item-text,
.sidebar.collapsed .nav-menu-text,
.sidebar.collapsed .nav-submenu,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-brand-chevron,
.sidebar.collapsed .nav-menu-chevron,
.sidebar.collapsed .nav-link-chevron {
  display: none !important;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0.5rem;
}

.sidebar-header {
  min-height: auto;
  flex-shrink: 0;
  padding: 0.75rem 0.85rem;
}

/* Sidebar toggle - top bar style */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: #6b7280;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-toggle-btn:hover {
  background: var(--sidebar-accent-bg);
  color: var(--sidebar-accent);
}

.sidebar-toggle-btn i {
  font-size: 1.1rem;
}

.topbar-toggle {
  margin-right: 0.25rem;
}

/* Company / Project selector - reference style */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  transition: background 0.15s;
  color: #1f2937;
}

.sidebar-brand:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #1f2937;
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.sidebar-brand-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

.sidebar-brand-chevron {
  font-size: 0.75rem;
  color: #9ca3af;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.sidebar-nav .sidebar-menu {
  padding: 0.5rem 0.5rem 1rem;
  list-style: none;
  margin: 0;
}

.nav-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0.25rem 0.75rem 0.5rem;
  list-style: none;
}

/* Main menu header - larger font, prominent (button for collapse toggle) */
.nav-menu-header {
  font-size: 0.95rem;
  font-weight: 700;
  color: #374151;
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-transform: none;
  letter-spacing: 0.02em;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  margin: 0.15rem 0.25rem 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  text-align: left;
  font: inherit;
}

.nav-menu-header:hover {
  background: rgba(0, 0, 0, 0.03);
}

.nav-menu-icon {
  font-size: 1.1rem;
  color: #6b7280;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.nav-menu-chevron {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-left: auto;
  transition: transform 0.2s;
}

.nav-menu-group.collapsed .nav-menu-chevron {
  transform: rotate(-90deg);
}

.nav-menu-group.collapsed .nav-submenu {
  display: none;
}

/* Planner group: always show submenu (Planner Dashboard, Day Planner Masters) when expanded */
.nav-menu-group.default-open:not(.collapsed) .nav-submenu {
  display: block;
}

/* When sidebar is collapsed, show submenu flyout on hover */
.sidebar.collapsed .nav-menu-group {
  position: relative;
}

.sidebar.collapsed .nav-menu-group:hover .nav-submenu {
  display: block !important;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0.5rem 0;
  margin-left: 0.25rem;
  z-index: 1050;
}

.sidebar.collapsed .nav-menu-group:hover .nav-submenu .submenu-link {
  padding: 0.5rem 0.85rem;
  white-space: nowrap;
}

.nav-menu-group {
  margin-bottom: 0.1rem;
}

/* Submenu */
.nav-submenu {
  list-style: none;
  padding: 0 0 0.35rem 0;
  margin: 0 0 0 0.5rem;
  border-left: 1px solid #e5e7eb;
  margin-left: 1.75rem;
  padding-left: 0.4rem;
}

.nav-submenu li {
  margin: 0;
}

.submenu-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #4b5563;
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 0 6px 6px 0;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  width: 100%;
}

.submenu-link i {
  font-size: 0.95rem;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
  color: #6b7280;
}

.submenu-link:hover {
  background: #f3f4f6;
  color: var(--sidebar-accent);
}

.submenu-link:hover i {
  color: var(--sidebar-accent);
}

.submenu-link.active {
  background: var(--sidebar-accent-bg);
  color: var(--sidebar-accent);
  border-left-color: var(--sidebar-accent);
}

.submenu-link.active i {
  color: var(--sidebar-accent);
}

/* Top-level link (Overview) */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #4b5563;
  padding: 0.6rem 0.85rem;
  border-left: 3px solid transparent;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  margin: 0.15rem 0.25rem;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.sidebar-link .nav-item-icon {
  font-size: 1.15rem;
  width: 1.3rem;
  text-align: center;
  flex-shrink: 0;
  color: #6b7280;
}

.nav-link-chevron {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-left: auto;
}

.sidebar-link:hover {
  background: #f3f4f6;
  color: var(--sidebar-accent);
}

.sidebar-link:hover .nav-item-icon {
  color: var(--sidebar-accent);
}

.sidebar-link.active {
  background: var(--sidebar-accent-bg);
  color: var(--sidebar-accent);
  border-left-color: var(--sidebar-accent);
}

.sidebar-link.active .nav-item-icon {
  color: var(--sidebar-accent);
}

.sidebar-link.active .nav-link-chevron {
  color: var(--sidebar-accent);
}

/* Offcanvas: match brand style */
.sidebar-offcanvas .sidebar-brand {
  padding: 0.5rem 0;
}

.sidebar-offcanvas .sidebar-brand-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  font-size: 1rem;
}

.nav-icon {
  display: inline-block;
  width: 1.4rem;
  margin-right: 0.4rem;
  text-align: center;
  flex-shrink: 0;
}

/* === Main Content === */
.main-content {
  background: #fff;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-scroll {
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* === Topbar / Header - responsive === */
.topbar {
  min-height: 48px;
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
}

@media (min-width: 768px) {
  .topbar {
    padding: 0.5rem 1rem;
    min-height: 50px;
  }
}

/* Hamburger / menu button: touch-friendly on small screens */
.topbar .btn-link[data-bs-toggle="offcanvas"] {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: -0.25rem 0;
}

.topbar-inner {
  min-height: 36px;
}

.topbar-title {
  font-size: 0.95rem;
}

/* Card styling for dashboard */
.dashboard-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

/* Timeline styles for project dashboard */
.timeline,
.timeline-track {
  position: relative;
  padding-left: 0;
}

.timeline-track .timeline-meta {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

.timeline-item {
  position: relative;
  padding: 0.5rem 0;
  padding-left: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6c757d;
}

.timeline-item.completed::before {
  background: #198754;
}

.timeline-item.overdue::before {
  background: #dc3545;
}

.timeline-item.pending::before {
  background: #0d6efd;
}

/* === Offcanvas sidebar (mobile) - responsive === */
.sidebar-offcanvas {
  width: 280px;
  max-width: 85vw;
  transition: transform 0.25s ease-in-out;
}

@media (min-width: 400px) {
  .sidebar-offcanvas {
    width: 300px;
    max-width: 320px;
  }
}

.sidebar-offcanvas .offcanvas-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.sidebar-offcanvas .offcanvas-body {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-offcanvas .sidebar-nav .nav-link {
  color: #4b5563;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
}

.sidebar-offcanvas .sidebar-nav .nav-link:hover {
  background: #f3f4f6;
  color: var(--sidebar-accent);
}

.sidebar-offcanvas .nav-menu-header {
  padding: 0.65rem 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.sidebar-offcanvas .submenu-link {
  padding: 0.5rem 1rem 0.5rem 2.25rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* === Responsive Tables === */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
  min-width: 600px;
}

@media (max-width: 767.98px) {
  .table-responsive .table {
    font-size: 0.875rem;
  }
  .table-responsive .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* === Page Content - responsive headings & actions === */
main h1, main .h1, main h2, main .h2 {
  word-wrap: break-word;
}

.d-flex.justify-content-between.align-items-center {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.d-flex.justify-content-between.align-items-center h1,
.d-flex.justify-content-between.align-items-center .h2 {
  margin-bottom: 0;
}

/* === Cards - responsive padding === */
.card {
  overflow: hidden;
}

.card-body {
  overflow-x: auto;
}

/* === Auth layout (login page) === */
.auth-wrapper {
  overflow-x: hidden;
}

.auth-wrapper .navbar-brand {
  max-width: 60vw;
}

/* === Prevent overflow from content === */
img, video, iframe {
  max-width: 100%;
  height: auto;
}

pre, code {
  overflow-x: auto;
  max-width: 100%;
}

/* === Form rows on mobile === */
.row.g-2 .col-md-3,
.row.g-2 .col-md-4,
.row.g-2 .col-md-2 {
  min-width: 0;
}

/* === Planner Dashboard === */
.planner-flow-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-left: 4px solid var(--sidebar-accent, #6366f1);
}

.planner-flow-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0;
}

.planner-flow-steps .flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  min-width: 70px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.planner-flow-steps .flow-step:hover {
  transform: translateY(-1px);
}

.planner-flow-steps .flow-step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.planner-flow-steps .flow-step-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.planner-flow-steps .flow-step-count {
  font-size: 0.85rem;
  font-weight: 700;
}

.flow-step-draft .flow-step-icon { background: rgba(108, 117, 125, 0.2); color: #6c757d; }
.flow-step-draft .flow-step-label { color: #6c757d; }
.flow-step-pending .flow-step-icon { background: rgba(255, 193, 7, 0.3); color: #b38600; }
.flow-step-pending .flow-step-label { color: #856404; }
.flow-step-approved .flow-step-icon { background: rgba(25, 135, 84, 0.2); color: #198754; }
.flow-step-approved .flow-step-label { color: #198754; }
.flow-step-execute .flow-step-icon { background: rgba(13, 110, 253, 0.2); color: #0d6efd; }
.flow-step-execute .flow-step-label { color: #0d6efd; }

.flow-step-arrow {
  color: #cbd5e1;
  font-size: 0.9rem;
  flex-shrink: 0;
}

@media (max-width: 576px) {
  .flow-step-arrow { display: none !important; }
  .planner-flow-steps { justify-content: flex-start; gap: 0.5rem; }
}

.planner-dashboard-header {
  border-left: 4px solid #0d6efd;
}

.planner-kpi-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.planner-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
}

@media print {
  .btn, .sidebar, .topbar, .no-print {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }
}