/**
 * Perfex Theme — base layer
 * Consumes --pt-* CSS variables injected by the module.
 * Applies globally to admin shell + common components.
 */

/* ---------- Shell ---------- */
body.admin.pt-theme,
body.pt-theme {
  background-color: var(--pt-content-bg) !important;
  color: var(--pt-text);
}

body.admin.pt-theme #wrapper {
  background-color: var(--pt-content-bg);
}

body.admin.pt-theme #header {
  background: var(--pt-header-bg) !important;
  border-bottom: 1px solid var(--pt-border);
  box-shadow: none;
}

body.admin.pt-theme #header .navbar-nav > li > a {
  color: var(--pt-muted);
}

body.admin.pt-theme #header .navbar-nav > li > a:hover,
body.admin.pt-theme #header .navbar-nav > li > a:focus {
  color: var(--pt-primary);
}

/* Sidebar */
body.admin.pt-theme #menu.sidebar,
body.admin.pt-theme aside#menu {
  background: var(--pt-sidebar-bg) !important;
  border-right: 1px solid var(--pt-border);
}

body.admin.pt-theme #side-menu li a,
body.admin.pt-theme #setup-menu li a {
  color: var(--pt-sidebar-text) !important;
  border-radius: var(--pt-radius-sm);
  margin: 2px 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

body.admin.pt-theme #side-menu li a:hover,
body.admin.pt-theme #setup-menu li a:hover,
body.admin.pt-theme #side-menu li.active > a,
body.admin.pt-theme #setup-menu li.active > a {
  background: var(--pt-primary-soft) !important;
  color: var(--pt-sidebar-active) !important;
}

body.admin.pt-theme #side-menu li.active > a .menu-icon,
body.admin.pt-theme #side-menu li a:hover .menu-icon {
  color: var(--pt-sidebar-active) !important;
}

/* Submenu: keep icon space readable under themed margins */
body.admin.pt-theme #side-menu li .nav-second-level li a,
body.admin.pt-theme #setup-menu li .nav-second-level li a {
  margin: 1px 8px;
  padding-left: 42px !important;
}

body.admin.pt-theme #side-menu li .nav-second-level a .menu-icon,
body.admin.pt-theme #setup-menu li .nav-second-level a .menu-icon {
  width: 16px;
  font-size: 14px;
  margin-right: 10px;
  color: var(--pt-sidebar-text);
  opacity: 0.9;
}

body.admin.pt-theme #setup-menu-wrapper {
  background: var(--pt-sidebar-bg);
}

/* Content area */
body.admin.pt-theme .content {
  color: var(--pt-text);
}

/* ---------- Panels / cards ---------- */
body.pt-theme .panel_s,
body.admin.pt-theme .panel_s {
  background: var(--pt-card-bg);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
  overflow: hidden;
}

body.pt-theme.pt-no-shadow .panel_s {
  box-shadow: none;
}

body.pt-theme .panel_s > .panel-heading,
body.pt-theme .panel_s > .panel-body,
body.pt-theme .panel_s > .panel-footer {
  background: transparent;
  border-color: var(--pt-border);
}

body.pt-theme .panel-title {
  color: var(--pt-text);
}

/* ---------- Buttons ---------- */
body.pt-theme .btn {
  border-radius: var(--pt-radius-sm);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

body.pt-theme .btn-primary,
body.pt-theme .btn-info {
  background-color: var(--pt-primary) !important;
  border-color: var(--pt-primary) !important;
  color: #fff !important;
}

body.pt-theme .btn-primary:hover,
body.pt-theme .btn-primary:focus,
body.pt-theme .btn-primary:active,
body.pt-theme .btn-info:hover,
body.pt-theme .btn-info:focus,
body.pt-theme .btn-info:active {
  background-color: var(--pt-primary-hover) !important;
  border-color: var(--pt-primary-hover) !important;
}

body.pt-theme .btn-success {
  background-color: var(--pt-success) !important;
  border-color: var(--pt-success) !important;
}

body.pt-theme .btn-danger {
  background-color: var(--pt-danger) !important;
  border-color: var(--pt-danger) !important;
}

body.pt-theme .btn-warning {
  background-color: var(--pt-warning) !important;
  border-color: var(--pt-warning) !important;
  color: #fff !important;
}

body.pt-theme .btn-default {
  background: var(--pt-card-bg);
  border-color: var(--pt-border);
  color: var(--pt-text);
}

body.pt-theme .btn-default:hover {
  background: var(--pt-content-bg);
  border-color: var(--pt-border);
}

/* ---------- Forms ---------- */
body.pt-theme .form-control,
body.pt-theme .input-group-addon,
body.pt-theme .bootstrap-select > .dropdown-toggle,
body.pt-theme .select2-container--default .select2-selection--single,
body.pt-theme .select2-container--default .select2-selection--multiple {
  border-radius: var(--pt-radius-sm) !important;
  border-color: var(--pt-border);
  background-color: var(--pt-card-bg);
  color: var(--pt-text);
  box-shadow: none;
}

body.pt-theme .form-control:focus {
  border-color: var(--pt-primary);
  box-shadow: 0 0 0 3px var(--pt-primary-soft);
}

/* ---------- Tables ---------- */
body.pt-theme .table > thead > tr > th,
body.pt-theme table.dataTable thead > tr > th,
body.pt-theme .table > thead > tr > td {
  color: var(--pt-muted);
  border-bottom-color: var(--pt-border);
  background: transparent;
}

body.pt-theme .table > tbody > tr > td {
  border-top-color: var(--pt-border);
  color: var(--pt-text);
}

body.pt-theme .table-striped > tbody > tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.015);
}

body.pt-theme a:not(.btn):not(.label):not(.dropdown-item) {
  color: var(--pt-primary);
}

body.pt-theme a:not(.btn):not(.label):hover {
  color: var(--pt-primary-hover);
}

/* ---------- Modals ---------- */
body.pt-theme .modal-content {
  border-radius: var(--pt-radius);
  border: 1px solid var(--pt-border);
  box-shadow: var(--pt-shadow);
  background: var(--pt-card-bg);
  overflow: hidden;
}

body.pt-theme .modal-header {
  background: var(--pt-card-bg);
  border-bottom-color: var(--pt-border);
  color: var(--pt-text);
}

body.pt-theme .modal-footer {
  border-top-color: var(--pt-border);
  background: var(--pt-card-bg);
}

/* ---------- Badges / labels / pills ---------- */
body.pt-theme .label,
body.pt-theme .badge {
  border-radius: var(--pt-radius-pill);
  font-weight: 600;
}

body.pt-theme .label-info,
body.pt-theme .badge-info {
  background-color: var(--pt-primary);
}

body.pt-theme .label-success {
  background-color: var(--pt-success);
}

body.pt-theme .label-danger {
  background-color: var(--pt-danger);
}

body.pt-theme .label-warning {
  background-color: var(--pt-warning);
}

/* ---------- Nav tabs ---------- */
body.pt-theme .nav-tabs > li > a {
  border-radius: var(--pt-radius-sm) var(--pt-radius-sm) 0 0;
  color: var(--pt-muted);
}

body.pt-theme .nav-tabs > li.active > a,
body.pt-theme .nav-tabs > li.active > a:hover,
body.pt-theme .nav-tabs > li.active > a:focus {
  color: var(--pt-primary);
  border-color: var(--pt-border) var(--pt-border) transparent;
  background: var(--pt-card-bg);
}

body.pt-theme .nav-tabs-segmented > li > a,
body.pt-theme .nav-tabs-horizontal.nav-tabs-segmented > li > a {
  border-radius: var(--pt-radius-pill) !important;
}

body.pt-theme .nav-tabs-segmented > li.active > a {
  background: var(--pt-primary-soft) !important;
  color: var(--pt-primary) !important;
  border-color: transparent !important;
}

/* ---------- Dropdowns ---------- */
body.pt-theme .dropdown-menu {
  border-radius: var(--pt-radius-sm);
  border-color: var(--pt-border);
  box-shadow: var(--pt-shadow);
  background: var(--pt-card-bg);
}

body.pt-theme .dropdown-menu > li > a {
  color: var(--pt-text);
}

body.pt-theme .dropdown-menu > li > a:hover {
  background: var(--pt-primary-soft);
  color: var(--pt-primary);
}

/* ---------- Alerts ---------- */
body.pt-theme .alert {
  border-radius: var(--pt-radius-sm);
}

/* ---------- Progress ---------- */
body.pt-theme .progress {
  border-radius: var(--pt-radius-pill);
  background: var(--pt-border);
  box-shadow: none;
  overflow: hidden;
}

body.pt-theme .progress-bar {
  background-color: var(--pt-primary);
}

/* ---------- Tailwind primary overrides (build-time blues) ---------- */
body.pt-theme .tw-bg-primary-600,
body.pt-theme .tw-bg-primary-500,
body.pt-theme .tw-bg-primary-700 {
  background-color: var(--pt-primary) !important;
}

body.pt-theme .tw-text-primary-600,
body.pt-theme .tw-text-primary-500,
body.pt-theme .tw-text-primary-700,
body.pt-theme .tw-text-primary-800 {
  color: var(--pt-primary) !important;
}

body.pt-theme .tw-border-primary-600,
body.pt-theme .tw-border-primary-500 {
  border-color: var(--pt-primary) !important;
}

body.pt-theme .tw-ring-primary-500 {
  --tw-ring-color: var(--pt-primary-soft);
}

/* ---------- Search ---------- */
body.pt-theme #top_search {
  margin-left: 0.5rem;
  align-items: center;
}

body.admin.pt-theme #header button.hide-menu {
  margin-right: 0.35rem;
}

body.pt-theme #top_search input,
body.pt-theme #search_input,
body.pt-theme .top-search-input {
  border-radius: var(--pt-radius-pill) !important;
  border: 1px solid var(--pt-border) !important;
  background: var(--pt-content-bg) !important;
  padding-left: 2.5rem !important;
  padding-right: 1rem !important;
}

body.pt-theme #top_search_button {
  left: 0.55rem !important;
  top: 50% !important;
  transform: translateY(-50%);
  margin-top: 0.25rem; /* match input tw-mt-2 visual center */
}

body.pt-theme #top_search_button button {
  padding: 0.35rem !important;
  line-height: 1;
}

/* ---------- Pagination ---------- */
body.pt-theme .pagination > li > a,
body.pt-theme .pagination > li > span {
  border-radius: var(--pt-radius-sm);
  border-color: var(--pt-border);
  color: var(--pt-text);
  margin: 0 2px;
}

body.pt-theme .pagination > .active > a,
body.pt-theme .pagination > .active > span {
  background: var(--pt-primary);
  border-color: var(--pt-primary);
}

/* ---------- Customer profile left tabs ---------- */
body.pt-theme.customer-profile .md\:tw-max-w-64:has(.customer-tabs),
body.pt-theme #wrapper.customer_profile .md\:tw-max-w-64:has(nav.customer-tabs) {
  background: var(--pt-card-bg);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
  padding: 12px;
  align-self: flex-start;
}

/* Fallback when :has() unsupported — style the nav itself */
body.pt-theme nav.customer-tabs {
  background: var(--pt-card-bg);
  border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
  padding: 10px 8px;
}

body.pt-theme .md\:tw-max-w-64:has(nav.customer-tabs) nav.customer-tabs {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

body.pt-theme nav.customer-tabs a {
  color: var(--pt-text) !important;
  border-radius: var(--pt-radius-sm) !important;
}

body.pt-theme nav.customer-tabs a:hover {
  background: var(--pt-primary-soft) !important;
  color: var(--pt-primary) !important;
}

body.pt-theme nav.customer-tabs a.tw-bg-neutral-50,
body.pt-theme nav.customer-tabs a.tw-text-primary-600 {
  background: var(--pt-primary-soft) !important;
  color: var(--pt-primary) !important;
}

body.pt-theme nav.customer-tabs a .fa-fw,
body.pt-theme nav.customer-tabs a i {
  color: inherit;
}

/* Costumized client overview cards follow theme tokens */
body.pt-theme .ccp-card {
  background: var(--pt-card-bg) !important;
  border-color: var(--pt-border) !important;
  border-radius: var(--pt-radius) !important;
  box-shadow: var(--pt-shadow);
  color: var(--pt-text);
}

body.pt-theme .ccp-title,
body.pt-theme .ccp-kpi-value,
body.pt-theme .ccp-info-value {
  color: var(--pt-text) !important;
}

body.pt-theme .ccp-kpi-title,
body.pt-theme .ccp-info-label,
body.pt-theme .ccp-feed-meta {
  color: var(--pt-muted) !important;
}

body.pt-theme .ccp-admin-tag {
  background: var(--pt-content-bg) !important;
  color: var(--pt-text) !important;
}

body.pt-theme .ccp-feed-item {
  border-bottom-color: var(--pt-border) !important;
}

/* ---------- Auth / login ---------- */
html.pt-theme body.login_admin,
html.pt-theme body.authentication,
body.login_admin.pt-theme,
body.authentication.pt-theme {
  background: var(--pt-content-bg) !important;
  color: var(--pt-text);
}

html.pt-theme .authentication .btn-primary,
html.pt-theme body.login_admin .btn-primary,
body.login_admin.pt-theme .btn-primary,
body.authentication.pt-theme .btn-primary {
  background: var(--pt-primary) !important;
  border-color: var(--pt-primary) !important;
  border-radius: var(--pt-radius-pill);
}

html.pt-theme .authentication .form-control,
html.pt-theme body.login_admin .form-control,
body.login_admin.pt-theme .form-control,
body.authentication.pt-theme .form-control {
  border-radius: var(--pt-radius-sm);
  border-color: var(--pt-border);
}

html.pt-theme body.login_admin .tw-bg-white,
html.pt-theme body.authentication .tw-bg-white {
  background-color: var(--pt-card-bg) !important;
  border-radius: var(--pt-radius);
  box-shadow: var(--pt-shadow);
}

/* ---------- Kanban ---------- */
body.pt-theme .kan-ban-col .panel_s,
body.pt-theme .kanban-col .panel_s {
  border-radius: var(--pt-radius);
}

/* ---------- Density: compact ---------- */
body.pt-theme.pt-density-compact .panel_s > .panel-body,
body.pt-theme.pt-density-compact .panel_s > .panel-heading {
  padding-top: 10px;
  padding-bottom: 10px;
}

body.pt-theme.pt-density-compact #side-menu li a,
body.pt-theme.pt-density-compact #setup-menu li a {
  padding-top: 7px;
  padding-bottom: 7px;
}

body.pt-theme.pt-density-compact .table > thead > tr > th,
body.pt-theme.pt-density-compact .table > tbody > tr > td,
body.pt-theme.pt-density-compact table.dataTable thead > tr > th,
body.pt-theme.pt-density-compact table.dataTable tbody > tr > td {
  padding-top: 6px;
  padding-bottom: 6px;
}

body.pt-theme.pt-density-compact .btn {
  padding-top: 5px;
  padding-bottom: 5px;
}

body.pt-theme.pt-density-compact .form-group {
  margin-bottom: 12px;
}

body.pt-theme.pt-density-compact .content {
  padding-top: 12px;
}

/* ---------- Mobile tenant admin shell (viewport only) ---------- */
@media (max-width: 768px) {
  body.admin.pt-theme #wrapper {
    overflow-x: hidden;
  }

  body.admin.pt-theme .content {
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 12px;
    padding-bottom: 20px;
  }

  body.admin.pt-theme #header .navbar-nav > li > a,
  body.admin.pt-theme #header button.hide-menu,
  body.admin.pt-theme #header .navbar-toggle {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.admin.pt-theme .widget,
  body.dashboard .widget {
    width: 100% !important;
    max-width: 100%;
    float: none;
    padding-left: 0;
    padding-right: 0;
    margin-bottom: 12px;
  }

  body.admin.pt-theme .widget .panel-body,
  body.dashboard .widget .panel-body {
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.admin.pt-theme .widget .table-responsive,
  body.admin.pt-theme .widget .dataTables_wrapper {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
