/*
 * QSS Business Application UI Template
 * Copyright (c) Quintessential Software Solutions Pvt Ltd.
 * Reusable Bootstrap 5 theme for client-owned business applications.
 */
:root {
  --qss-primary: #155e75;
  --qss-secondary: #0f766e;
  --qss-accent: #d97706;
  --qss-page-bg: #f5f7fa;
  --qss-sidebar-bg: #17313b;
  --qss-sidebar-active: rgba(255, 255, 255, 0.12);
  --qss-border: #d8dee7;
  --qss-text: #1f2937;
  --qss-muted: #667085;
  --qss-radius: 8px;
  --qss-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--qss-page-bg);
  color: var(--qss-text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.94rem;
  letter-spacing: 0;
}

a {
  color: var(--qss-primary);
  text-decoration: none;
}

a:hover {
  color: var(--qss-secondary);
}

.btn {
  border-radius: 6px;
  font-weight: 600;
}

.btn-primary {
  --bs-btn-bg: var(--qss-primary);
  --bs-btn-border-color: var(--qss-primary);
  --bs-btn-hover-bg: #124e61;
  --bs-btn-hover-border-color: #124e61;
}

.btn-outline-primary {
  --bs-btn-color: var(--qss-primary);
  --bs-btn-border-color: var(--qss-primary);
  --bs-btn-hover-bg: var(--qss-primary);
  --bs-btn-hover-border-color: var(--qss-primary);
}

.text-primary {
  color: var(--qss-primary) !important;
}

.bg-primary {
  background-color: var(--qss-primary) !important;
}

.required::after {
  content: " *";
  color: #dc3545;
  font-weight: 700;
}

.form-control,
.form-select {
  border-color: var(--qss-border);
  border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--qss-secondary);
  box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.14);
}

.form-text {
  color: var(--qss-muted);
}

.qss-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(145deg, rgba(21, 94, 117, 0.94), rgba(15, 118, 110, 0.86)),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-panel {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1fr 430px;
  min-height: 620px;
  background: #ffffff;
  border-radius: var(--qss-radius);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(2, 8, 23, 0.24);
}

.login-brand {
  color: #ffffff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(rgba(23, 49, 59, 0.72), rgba(23, 49, 59, 0.84)),
    url("https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: contain;
  background: #ffffff;
  padding: 8px;
}

.brand-logo-sm {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  padding: 4px;
}

.login-brand h1 {
  max-width: 520px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
  margin: 0;
}

.login-form-wrap {
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main"
    "sidebar footer";
}

.app-sidebar {
  grid-area: sidebar;
  background: var(--qss-sidebar-bg);
  color: #d9e5eb;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1040;
}

.sidebar-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-client {
  min-width: 0;
}

.topbar-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-client strong {
  display: block;
  line-height: 1.2;
}

.sidebar-nav {
  padding: 14px 12px 24px;
}

.nav-group {
  background: transparent;
  border: 0;
  margin-bottom: 8px;
}

.nav-group-toggle {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9fb3bd;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

.nav-group-toggle:hover,
.nav-group-toggle:not(.collapsed) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-group-toggle .bi-chevron-down {
  transition: transform 0.18s ease;
}

.nav-group-toggle:not(.collapsed) .bi-chevron-down {
  transform: rotate(180deg);
}

.nav-group-links {
  padding-top: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #e8f0f3;
  min-height: 42px;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: #ffffff;
  background: var(--qss-sidebar-active);
}

.app-topbar {
  grid-area: topbar;
  background: #ffffff;
  border-bottom: 1px solid var(--qss-border);
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-main {
  grid-area: main;
  padding: 22px;
  min-width: 0;
}

.app-footer {
  grid-area: footer;
  border-top: 1px solid var(--qss-border);
  background: #ffffff;
  color: var(--qss-muted);
  padding: 12px 22px;
  font-size: 0.84rem;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-heading h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.25;
}

.page-heading p {
  color: var(--qss-muted);
  margin: 4px 0 0;
}

.card {
  border: 1px solid var(--qss-border);
  border-radius: var(--qss-radius);
  box-shadow: none;
}

.metric-card {
  min-height: 128px;
}

.metric-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(21, 94, 117, 0.1);
  color: var(--qss-primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.table {
  vertical-align: middle;
}

.table thead th {
  color: #344054;
  background: #f8fafc;
  border-bottom: 1px solid var(--qss-border);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.dataTables_wrapper .dt-buttons .btn,
.dt-container .dt-buttons .btn {
  margin-right: 6px;
  margin-bottom: 8px;
}

.dataTables_wrapper .dt-buttons,
.dt-container .dt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.dataTables_wrapper .dt-buttons .btn,
.dataTables_wrapper .dt-buttons .dt-button,
.dt-container .dt-buttons .btn,
.dt-container .dt-buttons .dt-button {
  min-width: 68px;
  width: auto !important;
  flex: 0 0 auto !important;
  margin: 0;
  border: 1px solid #98a2b3 !important;
  background: #ffffff !important;
  color: #344054 !important;
  box-shadow: none !important;
  opacity: 1;
}

.dataTables_wrapper .dt-buttons .btn:hover,
.dataTables_wrapper .dt-buttons .btn:focus,
.dataTables_wrapper .dt-buttons .dt-button:hover,
.dataTables_wrapper .dt-buttons .dt-button:focus,
.dt-container .dt-buttons .btn:hover,
.dt-container .dt-buttons .btn:focus,
.dt-container .dt-buttons .dt-button:hover,
.dt-container .dt-buttons .dt-button:focus {
  border-color: #475467 !important;
  background: #f2f4f7 !important;
  color: #101828 !important;
  box-shadow: 0 0 0 0.2rem rgba(71, 84, 103, 0.14) !important;
}

.dataTables_wrapper .dt-buttons .btn:active,
.dataTables_wrapper .dt-buttons .dt-button:active,
.dt-container .dt-buttons .btn:active,
.dt-container .dt-buttons .dt-button:active {
  background: #e4e7ec !important;
  color: #101828 !important;
}

.table-actions {
  white-space: nowrap;
}

.filter-bar {
  background: #ffffff;
  border: 1px solid var(--qss-border);
  border-radius: var(--qss-radius);
  padding: 16px;
  margin-bottom: 18px;
}

.line-table input,
.line-table select {
  min-width: 110px;
}

.attachment-drop {
  border: 1px dashed #9aa7b6;
  background: #f8fafc;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--qss-muted);
}

.report-paper {
  background: #ffffff;
  border: 1px solid var(--qss-border);
  border-radius: 8px;
  padding: 28px;
}

.report-title {
  border-bottom: 2px solid var(--qss-primary);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.error-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.error-card {
  max-width: 620px;
  width: 100%;
  text-align: center;
}

.mobile-sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .login-panel {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 300px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main"
      "footer";
  }

  .app-sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 280px;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1035;
  }
}

@media (max-width: 575.98px) {
  .qss-login,
  .app-main {
    padding: 14px;
  }

  .login-brand,
  .login-form-wrap {
    padding: 28px 22px;
  }

  .app-topbar {
    padding: 0 14px;
  }

  .page-heading {
    flex-direction: column;
  }
}

@media print {
  .app-sidebar,
  .app-topbar,
  .app-footer,
  .no-print,
  .filter-bar {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .app-main {
    padding: 0;
  }

  .report-paper {
    border: 0;
    padding: 0;
  }

  body {
    background: #ffffff;
  }
}
