/* 1. VARIABLES & THEME */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --accent: #f59e0b;
  --radius: 0.375rem;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  color-scheme: light;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html.theme-dark {
  --bg: #020617;
  --surface: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --border: #1e293b;
  color-scheme: dark;
}

/* Hamburger menu icon */
.menu-toggle {
  display: none; /* Hidden by default on larger screens */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1000; /* Ensure it's above other content */
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  position: relative;
}

.hamburger::before, .hamburger::after {
  content: '';
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  position: absolute;
  transition: transform 0.3s ease;
}

.hamburger::before {
  top: -8px;
}

.hamburger::after {
  top: 8px;
}

/* When sidebar is open */
.layout.sidebar-open .hamburger {
  background: transparent;
}

.layout.sidebar-open .hamburger::before {
  transform: translateY(8px) rotate(45deg);
}

.layout.sidebar-open .hamburger::after {
  transform: translateY(-8px) rotate(-45deg);
}

/* 2. BASE & LAYOUT */
*, *::before, *::after {
  box-sizing: border-box;
}
html, body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.layout {
  display: flex;
  min-height: 100dvh;
  position: relative; /* For sidebar overlay */
}
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  transition: transform 0.3s ease; /* For sliding animation */
}
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.main {
  padding: 1.25rem;
  overflow-y: auto;
}
.page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .menu-toggle {
    display: block; /* Show hamburger on narrow screens */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%); /* Hide sidebar off-screen */
    z-index: 999; /* Ensure it's above content */
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0); /* Show sidebar */
  }

  .layout.sidebar-open .content {
    /* Optional: Add an overlay or push content */
    /* For now, just let sidebar overlap */
  }

  .topnav__left {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .breadcrumbs {
    display: none; /* Hide breadcrumbs on mobile when menu is present */
  }
}

/* Customer Listing Cards */
.mobile-only-cards {
  display: none; /* Hidden by default */
}

@media (max-width: 768px) {
  .desktop-only {
    display: none; /* Hide table on mobile */
  }

  .mobile-only-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem; /* Reduced gap between cards */
  }

  .customer-card {
    padding: 0.75rem; /* Reduced card padding */
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .customer-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem; /* Reduced margin */
    padding-bottom: 0.4rem; /* Reduced padding */
    border-bottom: 1px solid var(--border);
  }

  .customer-card .card-header h3 {
    margin: 0;
    font-size: 1rem; /* Slightly reduced font size */
    display: flex;
    align-items: baseline; /* Align items on the same baseline */
    flex-wrap: wrap; /* Allow wrapping if space is tight */
  }

  .customer-card .card-header h3 a {
    margin-bottom: 0; /* Remove margin-bottom */
    margin-right: 0.25rem; /* Add a small margin to separate from account number */
  }

  .customer-card .card-header .account-number-small {
    font-size: 0.75rem; /* Slightly reduced font size */
    color: var(--muted);
    font-weight: normal;
  }

  .customer-card .card-header .card-header-actions {
    display: flex;
    gap: 0.5rem; /* Reduced gap */
  }

  .customer-card .card-body p {
    margin: 0.2rem 0; /* Reduced margin */
    font-size: 0.85rem; /* Slightly reduced font size */
  }

  .customer-card .card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem; /* Reduced gap */
    margin-top: 0.75rem; /* Reduced margin */
    padding-top: 0.4rem; /* Reduced padding */
    border-top: 1px solid var(--border);
  }

  .customer-card .card-actions .link {
    font-size: 0.85rem; /* Slightly reduced font size */
  }

  /* Further reduce padding on the main card container for mobile */
  section.card {
    padding: 0.5rem !important; /* Reduced padding on the main section */
  }

  .mobile-only-cards {
    gap: 0.5rem; /* Further reduced gap between cards */
  }

  .customer-card {
    padding: 0.5rem; /* Further reduced card padding */
  }

  .customer-card .card-header {
    margin-bottom: 0.3rem; /* Further reduced margin */
    padding-bottom: 0.3rem; /* Further reduced padding */
  }

  .customer-card .card-header h3 a {
    margin-bottom: 0; /* Remove margin-bottom */
    margin-right: 0.25rem; /* Add a small margin to separate from account number */
  }

  .customer-card .card-header .account-number-small {
    font-size: 0.75rem; /* Slightly reduced font size */
    color: var(--muted);
    font-weight: normal;
  }

  .customer-card .card-header .card-header-actions {
    display: flex;
    gap: 0.5rem; /* Reduced gap */
  }

  .customer-card .card-body p {
    margin: 0.15rem 0; /* Further reduced margin */
  }

  .customer-card .card-actions {
    margin-top: 0.5rem; /* Further reduced margin */
    padding-top: 0.3rem; /* Further reduced padding */
  }

  /* Hide desktop-only actions on mobile */
  .desktop-only-actions {
    display: none;
  }

  /* Reduce space in search filter toolbar on mobile */
  .toolbar {
    padding: 0.5rem; /* Reduced padding */
    margin-bottom: 0.75rem; /* Reduced margin */
    gap: 0.5rem; /* Reduced gap */
    flex-wrap: wrap; /* Allow items to wrap */
  }

  .toolbar__filters {
    flex-grow: 1; /* Allow filters to take available space */
    gap: 0.5rem; /* Reduced gap */
  }

  .toolbar__filters .input {
    flex-grow: 1; /* Allow input to take available space */
  }

  .toolbar__filters .btn {
    flex-shrink: 0; /* Prevent button from shrinking */
  }
}
/* 3. SIDEBAR & NAVIGATION */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem;
  text-decoration: none;
  color: inherit;
  height: 2rem;
}
.brand__logo {
  width: 28px;
  height: 28px;
}
.brand__name {
  font-weight: 700;
  font-size: 1.125rem;
}
.nav {
  flex-grow: 1;
}
.nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.nav__link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav__link:hover {
  background: var(--bg);
}
.nav__link.is-active {
  background: var(--primary);
  color: var(--primary-text);
}
.nav__link .nav__dot {
  display: none;
}
.nav__chev {
  margin-left: auto;
  opacity: 0.7;
  transition: transform 0.2s ease;
}
.nav__link[aria-expanded="true"] .nav__chev {
  transform: rotate(90deg);
}
.nav__children {
  margin: 0.25rem 0 0.5rem 0;
  padding-left: 1.5rem;
  list-style: none;
  display: none;
  border-left: 2px solid var(--border);
  margin-left: 1.25rem;
}
.nav__children[data-open="true"] {
  display: block;
}
.nav__child {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.nav__child:hover {
  color: var(--text);
  background: var(--bg);
}
.nav__child.is-active {
  color: var(--primary);
  background: transparent;
  font-weight: 600;
}
.sidebar__footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  flex-shrink: 0;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 1.125rem;
  font-weight: 600;
}
.breadcrumb-item a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumb-item a:hover {
  color: var(--text);
  text-decoration: underline;
}
.breadcrumb-item span {
  color: var(--text);
}
.breadcrumb-separator {
  color: var(--muted);
  font-weight: 400;
}

.flash-messages {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: var(--primary-text);
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0.95;
  transition: opacity 0.3s ease;
}

.alert:hover {
  opacity: 1;
}

.alert-success {
  background-color: var(--success);
}

.alert-error {
  background-color: var(--danger);
}

.alert-info {
  background-color: var(--primary);
}

.alert-warning {
  background-color: var(--accent);
}

/* 5. FORMS & BUTTONS (New) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.label {
  font-weight: 500;
}

.input, select, textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  padding: 0.375rem 0.5rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.form__footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  grid-column: 1 / -1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover {
  background: var(--bg);
}
.btn--primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-text);
}
.btn--success {
    background: var(--success);
    color: var(--primary-text);
    border-color: var(--success);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--muted);
  border-color: var(--muted);
  color: var(--primary-text);
}

/* 4. LISTING PAGE (TOOLBAR, TABLE, PAGINATION) */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 0.25rem 0.5rem;
}

.table th {
  font-weight: 600;
  color: #000000;
  font-size: 0.875rem;
  text-align: left;
}

.table td {
  font-size: 0.875rem;
}

.table tbody tr:nth-child(even) {
  background-color: var(--bg);
}

.table tbody tr:hover {
  background-color: var(--surface);
}


.pagination-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}

.pagination {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.page {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.page:hover {
  background-color: var(--bg);
}
.page.is-active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  font-weight: 700;
}

.ellipsis {
  padding: 0.375rem 0.75rem;
  color: var(--muted);
}

.link--danger {
  color: var(--danger);
}


.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}


.error-message {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.label {
  font-weight: 500;
}

.form-group.placeholder-label .label {
  display: none;
}

.form-group.placeholder-label .input {
  padding-top: 1.25rem;
  padding-bottom: 0.5rem;
}

.form-group.underline-label .input {
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  padding-left: 0;
}

.form-group.underline-label .label {
  display: none;
}

.layout.sidebar-collapsed .sidebar {
  width: 60px;
}

.layout.sidebar-collapsed .sidebar .brand__name,
.layout.sidebar-collapsed .sidebar .nav__link span,
.layout.sidebar-collapsed .sidebar .nav__chev,
.layout.sidebar-collapsed .sidebar .user__meta {
  display: none;
}

.layout.sidebar-collapsed .sidebar .nav__link {
  justify-content: center;
}

.layout.sidebar-collapsed .sidebar .nav__children {
  display: none !important;
}

.layout.sidebar-collapsed .sidebar .sidebar__footer {
  padding: 1rem 0.5rem;
}




