/* =========================================
   LOKALLI Performance Report
   Clean, presentation-ready styles
   ========================================= */

:root {
  --black:       #1A1A1A;
  --dark:        #293241;
  --blue:        #3B82F6;
  --blue-light:  #EBF2FF;
  --green:       #228B22;
  --green-light: #EDFAED;
  --amber:       #F59E0B;
  --amber-light: #FFF8E1;
  --gray-bg:     #F5F5F5;
  --gray-100:    #EEEEEE;
  --gray-200:    #E0E0E0;
  --gray-400:    #9E9E9E;
  --gray-600:    #757575;
  --gray-800:    #424242;
  --white:       #FFFFFF;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-bg);
  color: var(--black);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Top bar (controls, hidden in PDF) ---- */
.topbar {
  background: var(--black);
  color: var(--white);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-logo-img {
  height: 28px;
  width: auto;
  filter: invert(1);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.controls label {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--gray-400);
}
.controls input[type="date"],
.controls input[type="text"],
.controls select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 12px;
  outline: none;
  width: 120px;
}
.controls input[type="text"] {
  width: 110px;
}
.controls select {
  width: 130px;
  cursor: pointer;
}
.controls select option {
  background: var(--black);
  color: var(--white);
}
.controls input:focus,
.controls select:focus {
  border-color: var(--blue);
}
.controls input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Buttons */
.btn {
  padding: 6px 16px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-primary {
  background: var(--black);
  color: var(--white);
  border: 1px solid var(--white);
}
.btn-primary:hover { background: var(--gray-800); }
.btn-outline {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--white);
}
.btn-help {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}
.btn-sm {
  padding: 3px 10px;
  font-size: 11px;
}

/* ---- Report container ---- */
#report {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ---- Report header ---- */
.report-header {
  padding: 40px 0 20px;
}
.report-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.report-header-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.report-logo-img {
  height: 44px;
  width: auto;
}
.report-brand-sub {
  font-size: 14px;
  color: var(--gray-600);
  margin-top: -2px;
}
.report-brand-sub strong {
  font-weight: 700;
  color: var(--black);
}
.report-header-month {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-600);
  text-align: right;
}

.report-client-info {
  margin-top: 8px;
}
.client-name {
  font-size: 26px;
  font-weight: 800;
  color: var(--black);
  margin-bottom: 4px;
}
.client-meta {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.5;
}
.client-meta strong {
  color: var(--black);
}

/* ---- Sections ---- */
.section {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 16px;
  border: 1px solid var(--gray-100);
  page-break-inside: avoid;
}
.section-header {
  margin-bottom: 20px;
}
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--black);
}
.section-subtitle {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}

.kpi-group-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 14px;
}

/* ---- KPI cards ---- */
.kpi-row {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.kpi-row:last-child {
  margin-bottom: 0;
}
.kpi-row-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-row-2 { grid-template-columns: repeat(2, 1fr); }

.kpi-card {
  background: var(--gray-bg);
  border-radius: var(--radius);
  padding: 18px 16px;
  border: 1px solid var(--gray-100);
}
.kpi-label {
  font-size: 11px;
  color: var(--gray-600);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--black);
  line-height: 1.1;
}

.kpi-card-views {
  border: 2px solid var(--blue);
  background: var(--blue-light);
}
.kpi-card-views .kpi-value { color: var(--blue); }

.kpi-card-engaged {
  border: 2px solid var(--green);
  background: var(--green-light);
}
.kpi-card-engaged .kpi-value { color: var(--green); }

/* ---- Page Views layout (2-column) ---- */
.pv-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
  align-items: start;
}
.pv-kpis {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-pages-list {
  list-style: decimal;
  padding-left: 20px;
  font-size: 13px;
}
.top-pages-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-100);
  line-height: 1.5;
}
.top-pages-list li:last-child {
  border-bottom: none;
}

.tp-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 4px;
}
.tp-badge-venue { background: var(--blue); color: var(--white); }
.tp-badge-deal  { background: var(--green); color: var(--white); }
.tp-badge-event { background: var(--amber); color: var(--white); }

/* ---- Hierarchy (Venue, Deals, Events) ---- */
.section-venue { border-left: 4px solid var(--blue); }
.section-deals { border-left: 4px solid var(--green); }
.section-events { border-left: 4px solid var(--amber); }

.hierarchy-item {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--gray-bg);
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
}
.hierarchy-item:last-child { margin-bottom: 0; }
.hierarchy-deal { border-left: 3px solid var(--green); }
.hierarchy-event { border-left: 3px solid var(--amber); }
.hierarchy-item h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 12px;
}
.kpi-row-compact .kpi-card {
  padding: 12px 14px;
}
.kpi-row-compact .kpi-value {
  font-size: 22px;
}
.deals-list, .events-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* GA note */
.ga-note {
  display: none;
  margin-top: 14px;
  font-size: 12px;
  color: var(--gray-400);
  font-style: italic;
  text-align: center;
  padding: 10px;
  background: var(--gray-bg);
  border-radius: 6px;
}

/* ---- Frames section ---- */
.section-frames {
  border-left: 4px solid var(--black);
}

.subsection {
  margin-top: 24px;
}
.subsection h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--black);
  color: var(--white);
  padding: 9px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
thead th:first-child { border-radius: 6px 0 0 0; }
thead th:last-child  { border-radius: 0 6px 0 0; }

tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--gray-100);
}
tbody tr:hover { background: var(--gray-bg); }
tbody tr:last-child td { border-bottom: none; }

td.loading, td.error, td.muted {
  text-align: center;
  color: var(--gray-400);
  padding: 24px;
  font-style: italic;
}
.muted {
  color: var(--gray-400);
  font-style: italic;
  font-size: 13px;
}
td.error { color: #dc3545; }

/* Chart */
.chart-container {
  margin-top: 24px;
  padding: 16px;
  background: var(--gray-bg);
  border-radius: var(--radius);
  /* PDF export: constrain width for A4 (~210mm) so charts fit and render crisply */
  max-width: 800px;
}
.chart-container img.chart-pdf-img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}
.modal-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 12px;
}
.modal-label input,
.modal-label select {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
  margin-top: 4px;
  outline: none;
  color: var(--black);
  background: var(--white);
}
.modal-label input:focus {
  border-color: var(--blue);
}
.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-actions .btn {
  color: var(--black);
  border-color: var(--gray-200);
}
.modal-actions .btn-primary {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}
.modal-actions .btn-primary:hover {
  background: #2563EB;
}
.modal-status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--gray-600);
}

/* Schedule list */
.sched-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
}
.sched-item:last-child { border-bottom: none; }
.sched-active {
  color: var(--green);
  font-weight: 600;
}
.sched-inactive {
  color: var(--gray-400);
  font-weight: 600;
}

/* ---- Customer grid (platform page) ---- */
.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.customer-card {
  background: var(--gray-bg);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.customer-card:hover {
  border-color: var(--gray-200);
  box-shadow: var(--shadow);
}
.customer-card-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.customer-card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--black);
}
.customer-card-email {
  font-size: 12px;
  color: var(--gray-600);
}
.customer-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}
.meta-badge-blue {
  background: var(--blue-light);
  color: var(--blue);
}
.meta-badge-green {
  background: var(--green-light);
  color: var(--green);
}
.customer-card-detail {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.5;
  word-break: break-all;
}
.customer-card-detail strong {
  color: var(--gray-800);
}
.customer-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.btn-outline-dark {
  background: transparent;
  color: var(--black);
  border: 1px solid var(--gray-200);
}
.btn-outline-dark:hover {
  background: var(--gray-bg);
  border-color: var(--gray-400);
}
.btn-danger-hover:hover {
  color: #dc3545;
  border-color: #dc3545;
  background: #fff5f5;
}
.btn-lg {
  padding: 10px 28px;
  font-size: 14px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-600);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 14px;
}

/* ---- Form components (customer form) ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
}
.form-label .required {
  color: #dc3545;
}
.form-label small {
  font-weight: 400;
}
.form-input {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  color: var(--black);
  background: var(--white);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.form-input:focus {
  border-color: var(--blue);
}
.form-textarea {
  min-height: 80px;
  resize: vertical;
}
.input-with-button {
  display: flex;
  gap: 8px;
}
.input-with-button .form-input {
  flex: 1;
}

.form-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 0 48px;
  max-width: 900px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}
.form-status {
  font-size: 13px;
  color: var(--gray-600);
}
.form-status-error {
  color: #dc3545;
}

/* Checkbox grid / list */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s ease;
  border: 1px solid transparent;
}
.checkbox-item:hover {
  background: var(--gray-bg);
}
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--blue);
}
.ga-page-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ga-page-title {
  font-weight: 500;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ga-page-path {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ga-page-views {
  font-size: 11px;
  color: var(--gray-600);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  word-break: break-all;
}
.tag-remove {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
}
.tag-remove:hover {
  opacity: 1;
}

/* Loading message */
.loading-msg {
  text-align: center;
  padding: 20px;
  color: var(--gray-400);
  font-style: italic;
  font-size: 13px;
}

/* ---- Help page ---- */
.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.help-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.help-table td:first-child {
  width: 120px;
  white-space: nowrap;
}
.help-table tr:last-child td {
  border-bottom: none;
}
code {
  background: var(--gray-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}
pre {
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Footer ---- */
.report-footer {
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
  color: var(--gray-400);
}
.report-footer p { font-weight: 500; }

/* ---- Print / PDF ---- */
@media print {
  .no-print { display: none !important; }
  body { background: white; }
  #report { padding: 0; max-width: none; }
  .section {
    box-shadow: none;
    border: 1px solid var(--gray-200);
    break-inside: avoid;
  }
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .controls { width: 100%; }
  .report-header-top { flex-direction: column; gap: 8px; }
  .kpi-row-3 { grid-template-columns: 1fr; }
  .kpi-row-2 { grid-template-columns: 1fr; }
  .pv-layout { grid-template-columns: 1fr; }
  .section { padding: 20px 16px; }
  .kpi-value { font-size: 26px; }
  .modal-card { margin: 16px; }
  .modal-row { grid-template-columns: 1fr; }
  .customer-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .form-actions-bar { flex-wrap: wrap; }
}

@media (min-width: 641px) and (max-width: 900px) {
  .kpi-row-3 { grid-template-columns: repeat(3, 1fr); }
  .kpi-row-2 { grid-template-columns: repeat(2, 1fr); }
}
