/**
 * CZPP custom.css — built on Perfex CRM stylesheets.
 *
 * Load order (matches Perfex app_admin_assets):
 *   reset.min.css → inter.css → vendor-admin.css → font-awesome →
 *   tailwind.css → style.css → forms.css → THIS FILE
 *
 * Do not restyle #header / #menu / #wrapper — those come from Perfex style.css.
 */

:root {
  --czpp-primary: #2563eb;
  --czpp-primary-dark: #1d4ed8;
  --czpp-success: #16a34a;
  --czpp-danger: #dc2626;
  --czpp-warning: #ea580c;
  --czpp-info: #0ea5e9;
  --czpp-muted: #6b7280;
  --czpp-border: #dce1e6;
  --czpp-surface: #ffffff;
  --czpp-soft: #f8fafc;
}

/* ------------------------------------------------------------------ */
/* Buttons — Tailwind can wash out Bootstrap .btn-primary; restore Perfex blue */
/* ------------------------------------------------------------------ */
.btn-primary {
  color: #fff !important;
  background-color: var(--czpp-primary) !important;
  border-color: var(--czpp-primary-dark) !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.open > .dropdown-toggle.btn-primary {
  color: #fff !important;
  background-color: var(--czpp-primary-dark) !important;
  border-color: #1e40af !important;
}

.btn-info {
  color: #fff !important;
  background-color: var(--czpp-info) !important;
  border-color: #0284c7 !important;
}
.btn-success {
  color: #fff !important;
  background-color: var(--czpp-success) !important;
  border-color: #15803d !important;
}
.btn-danger {
  color: #fff !important;
  background-color: var(--czpp-danger) !important;
  border-color: #b91c1c !important;
}
.btn-warning {
  color: #fff !important;
  background-color: var(--czpp-warning) !important;
  border-color: #c2410c !important;
}

.btn-default,
.btn-secondary {
  color: #374151;
  background-color: #fff;
  border-color: #d1d5db;
}
.btn-default:hover,
.btn-secondary:hover,
.btn-default:focus,
.btn-secondary:focus {
  color: #111827;
  background-color: #f9fafb;
  border-color: #9ca3af;
}

.btn-accent {
  color: #fff !important;
  background-color: #0f766e !important;
  border-color: #0f766e !important;
}
.btn-accent:hover {
  background-color: #115e59 !important;
  border-color: #115e59 !important;
  color: #fff !important;
}

.btn-block { display: block; width: 100%; }
.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 3px;
}
.btn-icon { padding: 4px 8px !important; }

/* ------------------------------------------------------------------ */
/* Page chrome (module pages inside Perfex #wrapper > .content) */
/* ------------------------------------------------------------------ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin: 0 0 20px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #1f2937;
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--czpp-muted);
  font-size: 13px;
}

.mbot15 { margin-bottom: 15px; }

/* ------------------------------------------------------------------ */
/* Stats / dashboard cards */
/* ------------------------------------------------------------------ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--czpp-surface);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.stat-card.accent { border-left: 3px solid var(--czpp-primary); }
.stat-card.green { border-left: 3px solid var(--czpp-success); }
.stat-card.orange { border-left: 3px solid var(--czpp-warning); }
.stat-label {
  font-size: 11px;
  color: var(--czpp-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  color: #111827;
}

/* ------------------------------------------------------------------ */
/* Panels — map CZPP .panel to Perfex panel_s look */
/* ------------------------------------------------------------------ */
.panel,
.panel_s {
  background: var(--czpp-surface);
  border: 1px solid var(--czpp-border);
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
}
.panel-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
}
.panel-body,
.panel_s > .panel-body {
  padding: 15px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 20px;
}
@media (max-width: 991px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ */
/* Tables */
/* ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}
table.data > thead > tr > th,
table.table thead > tr > th {
  background: var(--czpp-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--czpp-muted);
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb !important;
  padding: 10px 12px;
}
table.data > tbody > tr > td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.data > tbody > tr:hover > td {
  background: #fafbfc;
}

.actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.empty {
  text-align: center;
  color: #94a3b8;
  padding: 24px !important;
}

/* ------------------------------------------------------------------ */
/* Status badges (CZPP statusBadge()) */
/* ------------------------------------------------------------------ */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #eff6ff; color: #1d4ed8; }
.badge-green { background: #ecfdf3; color: #067647; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-purple { background: #f5f3ff; color: #6d28d9; }

.role-chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
}

/* ------------------------------------------------------------------ */
/* Forms / filters */
/* ------------------------------------------------------------------ */
.search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 15px;
  align-items: center;
}
.search-bar input,
.search-bar select {
  max-width: 260px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.form-grid .full,
.form-group.full { grid-column: 1 / -1; }

.form-group { margin-bottom: 15px; }
.form-group label,
.form-group .control-label,
.form-group-pf > .control-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.meta-list { margin: 0; }
.meta-list > div {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.meta-list dt {
  width: 110px;
  flex-shrink: 0;
  color: var(--czpp-muted);
  font-weight: 600;
  margin: 0;
}
.meta-list dd { margin: 0; flex: 1; }

.totals-box { max-width: 280px; margin-left: auto; }
.totals-box .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  margin: 0;
}
.totals-box .grand {
  font-weight: 700;
  border-top: 1px solid #e5e7eb;
  margin-top: 6px;
  padding-top: 8px;
}

.pdf-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.note-card {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}
.note-meta {
  font-size: 12px;
  color: var(--czpp-muted);
  margin-bottom: 4px;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}
.perm-ok { font-size: 13px; color: #067647; }

/* ------------------------------------------------------------------ */
/* Perfex-style accounting / estimate form shell */
/* ------------------------------------------------------------------ */
.panel_s.accounting-template {
  background: var(--czpp-surface);
  border: 1px solid var(--czpp-border);
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 0;
}
.accounting-template > .panel-body {
  padding: 20px;
}

.hr-panel-separator {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 0;
}

.edit_shipping_billing_info {
  float: right;
  color: var(--czpp-muted);
  font-size: 14px;
}
.edit_shipping_billing_info:hover { color: var(--czpp-primary); }

.accounting-template address {
  margin-bottom: 15px;
  font-style: normal;
  color: #374151;
  line-height: 1.5;
  min-height: 4.5em;
}
.accounting-template .bold { font-weight: 600; }

.mtop10 { margin-top: 10px; }
.mtop15 { margin-top: 15px; }
.mbot15 { margin-bottom: 15px; }
.mbot25 { margin-bottom: 25px; }
.no-mtop { margin-top: 0 !important; }
.no-mbot { margin-bottom: 0 !important; }
.hide { display: none !important; }

.show_quantity_as_wrapper .radio-inline {
  margin-left: 12px;
}
.show_quantity_as_wrapper .radio-inline label {
  font-weight: 500;
}

/* Perfex light items table (style.css .table.items) */
.table.items thead {
  background: #f3f4f6;
  color: #030712;
}
.table.items > thead:first-child > tr:first-child > th {
  border-top: 1px solid #e5e7eb;
}
.table.items thead th {
  border-right: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: #030712;
  background: #f3f4f6 !important;
}
.table.items thead th:first-child {
  border-left: 1px solid #e5e7eb;
  border-right: 0;
  min-width: auto;
}
.table.items tbody > tr > td,
.table.items thead > tr > th {
  padding: 8px 10px;
  vertical-align: top;
}
.table.items .main {
  background-color: #f9fafb;
  border-right: 1px solid #e5e7eb;
  border-left: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}
.table.items .main td {
  background-color: #f9fafb;
}
._transaction_form .table.items thead > tr > th {
  min-width: 100px;
}
._transaction_form .table.items thead > tr > th:last-child,
._transaction_form .table.items thead > tr > th:first-child {
  min-width: auto;
}

.table.items .dragger {
  cursor: grab;
  color: #9ca3af;
  width: 28px;
  text-align: center;
  vertical-align: middle !important;
}
.table.items .input-transparent {
  background: transparent;
  border: 0;
  border-top: 1px solid #e5e7eb;
  border-radius: 0;
  box-shadow: none;
  margin-top: 4px;
  padding-left: 0;
  padding-right: 0;
  text-align: right;
}
.table.items .amount {
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle !important;
}

/* Work-order form still uses dark estimate-items-table without .table.items */
table.estimate-items-table:not(.items) {
  width: 100%;
  background: #323a45;
  color: #fff;
  border-collapse: collapse;
}
table.estimate-items-table:not(.items) th {
  background: #323a45 !important;
  color: #fff !important;
  border-color: #3d4654 !important;
  padding: 10px 8px;
  font-size: 12px;
  text-transform: uppercase;
}
table.estimate-items-table:not(.items) td {
  background: #3a424e;
  border-color: #4a5563 !important;
  vertical-align: top;
  padding: 8px;
}
table.estimate-items-table:not(.items) input,
table.estimate-items-table:not(.items) textarea,
table.estimate-items-table:not(.items) select {
  color: #1e293b;
  width: 100%;
}

.btn-bottom-pusher { height: 70px; }
.btn-bottom-toolbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--czpp-border);
  padding: 12px 15px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  backdrop-filter: blur(4px);
}
.btn-bottom-toolbar.text-right { justify-content: flex-end; }
.btn-bottom-toolbar .btn-group { margin-left: 4px; }
.width200 { min-width: 200px; }

.s_table { margin-bottom: 15px; }

#discount_area .form-control,
#discount_area + tr .form-control {
  max-width: 120px;
  margin-left: auto;
}

.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.checkbox-primary label { font-weight: 500; }

.panel-section { margin-bottom: 8px; }
.form-group-pf { margin-bottom: 14px; }
.form-group-pf .form-control { width: 100%; }
.pf-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 15px;
}

.input-group-pf {
  display: flex;
  align-items: stretch;
}
.input-group-pf .addon {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--czpp-soft);
  border: 1px solid #d1d5db;
  border-right: 0;
  border-radius: 4px 0 0 4px;
  color: var(--czpp-muted);
  font-weight: 600;
  font-size: 13px;
}
.input-group-pf .form-control {
  border-radius: 0 4px 4px 0;
}

.date-row,
.right-meta-grid,
.accounting-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 991px) {
  .accounting-cols { grid-template-columns: 1fr; }
}

.items-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ */
/* Customer / work-order horizontal tabs (Perfex project-tabs style) */
/* ------------------------------------------------------------------ */
.customer-profile-tabs,
.project-tabs-wrap {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 15px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0;
}
.customer-profile-tabs a,
.project-tabs-wrap a {
  padding: 8px 12px;
  border-radius: 4px 4px 0 0;
  color: #475569;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.customer-profile-tabs a:hover,
.project-tabs-wrap a:hover {
  color: var(--czpp-primary);
  background: #f8fafc;
}
.customer-profile-tabs a.active,
.project-tabs-wrap a.active {
  background: #eff6ff;
  color: var(--czpp-primary-dark);
  border-bottom-color: var(--czpp-primary);
}

.nav-tabs-horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0 0 15px;
  border-bottom: 1px solid #e5e7eb;
}
.nav-tabs-horizontal > li { margin: 0; }
.nav-tabs-horizontal > li > a {
  display: inline-block;
  padding: 0.65rem 1rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  color: #475569;
  font-weight: 500;
}
.nav-tabs-horizontal > li > a:hover { color: var(--czpp-primary); }
.nav-tabs-horizontal > li > a.active {
  border-bottom-color: var(--czpp-primary);
  color: var(--czpp-primary);
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Alerts (module flash messages) */
/* ------------------------------------------------------------------ */
.alert {
  padding: 12px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  border: 1px solid transparent;
}
.alert-success,
.alert-error.success {
  background: #ecfdf3;
  border-color: #a7f3d0;
  color: #067647;
}
.alert-error,
.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.alert-warning {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

/* ------------------------------------------------------------------ */
/* Login (Perfex authentication-form-wrapper) */
/* ------------------------------------------------------------------ */
body.login_admin {
  min-height: 100vh;
}
.authentication-form-wrapper .company-logo h2 {
  letter-spacing: -0.02em;
}
