/* public/assets/app.css */

/* --- Modern base --- */
:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .12);
  --shadow: 0 10px 30px rgba(2, 6, 23, .06);
  --shadow-soft: 0 1px 0 rgba(2, 6, 23, .03);
  --radius: 18px;
  --radius-sm: 12px;

  --primary: #2563eb; /* bootstrap-ish but nicer */
  --primary-2: #1d4ed8;

  --sidebar: #0b1220;
  --sidebar-2: #0f172a;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: rgba(226,232,240,.75);

  --table-stripe: rgba(2, 6, 23, .02);
  --table-hover: rgba(37, 99, 235, .06);
}

/* Use system font stack that looks like "Inter-ish" without loading external fonts */
html, body {
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout shell --- */
.app-shell { display:flex; min-height:100vh; }

/* Sidebar */
.sidebar{
  width: 268px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  padding: 16px;
  display:flex;
  flex-direction:column;
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand{
  padding: 10px 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 12px;
}
.brand-title{
  font-weight: 800;
  letter-spacing: .2px;
}
.brand-sub{
  font-size: 12px;
  color: var(--sidebar-muted);
  margin-top: 2px;
}

.sidebar .nav-link{
  color: rgba(226,232,240,.86);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 2px 0;
  position: relative;
  transition: background .15s ease, color .15s ease, transform .05s ease;
}
.sidebar .nav-link:hover{
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar .nav-link.active{
  background: rgba(37,99,235,.16);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(37,99,235,.22);
}
.sidebar .nav-link.active::before{
  content:"";
  position:absolute;
  left: -6px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: rgba(37,99,235,.95);
}
.sidebar-footer{
  margin-top:auto;
  padding: 10px 10px 0;
  color: var(--sidebar-muted);
}

/* Main area */
.main { flex:1; display:flex; flex-direction:column; min-width:0; }

.topbar{
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.topbar .h5{
  font-weight: 800;
  letter-spacing: .2px;
}
.content{ padding: 18px; min-width:0; }

/* --- Cards --- */
.card{
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  background: var(--panel);
}
.card-header{
  background: transparent !important;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  font-weight: 700;
  color: rgba(15,23,42,.92);
}
.card-body{ padding: 14px; }

.kpi .kpi-label{
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px;
}
.kpi .kpi-value{
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .2px;
}
.kpi .kpi-small{
  font-size: 16px;
  font-weight: 800;
}

/* Make KPIs a bit "premium" */
.card.kpi{
  box-shadow: var(--shadow);
}
.card.kpi .card-body{
  padding: 16px;
}

/* Buttons slightly cleaner */
.btn-primary{
  background: var(--primary);
  border-color: rgba(37,99,235,.2);
  box-shadow: 0 6px 14px rgba(37,99,235,.18);
}
.btn-primary:hover{
  background: var(--primary-2);
  border-color: rgba(29,78,216,.25);
}
.btn-outline-secondary{
  border-color: rgba(15,23,42,.18);
}

/* Form controls */
.form-control, .form-select{
  border-radius: 12px;
  border-color: rgba(15,23,42,.12);
}
.form-control:focus, .form-select:focus{
  border-color: rgba(37,99,235,.35);
  box-shadow: 0 0 0 .2rem rgba(37,99,235,.12);
}

/* --- Tables: modern & calm --- */
.table{
  margin-bottom: 0;
}
.table thead th{
  font-size: 12px;
  text-transform: none;
  letter-spacing: .2px;
  color: rgba(15,23,42,.72);
  border-bottom: 1px solid var(--border-strong) !important;
  background: linear-gradient(180deg, rgba(248,250,252,.85), rgba(248,250,252,.55));
  position: sticky; /* makes headers stick inside scroll containers */
  top: 0;
  z-index: 2;
}
.table tbody td{
  border-top: 1px solid rgba(15,23,42,.06);
  vertical-align: middle;
}
.table-striped > tbody > tr:nth-of-type(odd) > *{
  background-color: var(--table-stripe);
}
.table tbody tr:hover > *{
  background-color: var(--table-hover);
}
.table-sm td, .table-sm th{
  padding: .5rem .6rem;
}

/* Numeric alignment & typography */
.num, .money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap; /* prevent "€" wrap */
}
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}

/* Small secondary text inside table cells */
.cell-sub{
  font-size: 12px;
  color: rgba(100,116,139,.95);
  line-height: 1.2;
}

/* Make table containers look nicer when scroll */
.table-responsive{
  border-radius: var(--radius);
  overflow: auto;
}

/* Subtle separators inside drilldown boxes */
.border.rounded{
  border-color: rgba(15,23,42,.10) !important;
  border-radius: 14px !important;
  background: rgba(248,250,252,.5);
}

/* Output console */
.console,
#output{
  background: #0b1220 !important;
  color: #dbeafe !important;
  border: 1px solid rgba(59,130,246,.12);
  border-radius: 14px;
  font-size: 12px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
#output{
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Allow shrink */
.card, .card-body, .col, [class*="col-"] { min-width: 0; }

/* Safety net: no horizontal scrollbar */
html, body { overflow-x: hidden; }

/* Badge: nicer */
.badge.text-bg-light.border{
  border-color: rgba(15,23,42,.10) !important;
  color: rgba(15,23,42,.72) !important;
  background: rgba(248,250,252,.9) !important;
}

/* Chart canvas: keep crisp */
canvas{
  image-rendering: -webkit-optimize-contrast;
}

/* --- Dashboard Customer Insights: prevent horizontal scroll, tighter typography --- */
#custInsightsCard {
  --ins-fs: 12.5px;
  --ins-fs-sub: 11.5px;
}

/* Make the inner tables fixed-layout and truncating */
#custInsightsCard table {
  table-layout: fixed;
  width: 100%;
}

#custInsightsCard th,
#custInsightsCard td {
  font-size: var(--ins-fs);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Allow the first column to have two lines (key + email/sub) */
#custInsightsCard td:first-child {
  white-space: normal;
}
#custInsightsCard td:first-child .fw-semibold {
  font-size: 13px;
}
#custInsightsCard td:first-child .cell-sub {
  font-size: var(--ins-fs-sub);
  line-height: 1.15;
}

/* Column widths to avoid overflow */
#custInsightsCard th:nth-child(1), #custInsightsCard td:nth-child(1) { width: 52%; } /* Kunde */
#custInsightsCard th:nth-child(2), #custInsightsCard td:nth-child(2) { width: 20%; } /* Affiliate */
#custInsightsCard th:nth-child(3), #custInsightsCard td:nth-child(3) { width: 12%; } /* Orders */
#custInsightsCard th:nth-child(4), #custInsightsCard td:nth-child(4) { width: 16%; } /* Netto */

/* Affiliate column: strict truncation */
#custInsightsCard td:nth-child(2) .mono,
#custInsightsCard td:nth-child(2) .fw-semibold {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Numbers: keep right-aligned but never overflow */
#custInsightsCard .num,
#custInsightsCard .money {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* The responsive wrapper should NOT create x-scroll here */
#custInsightsCard .table-responsive {
  overflow-x: hidden !important;
}

/* Slightly tighter header */
#custInsightsCard .card-header {
  padding: 10px 12px;
}
#custInsightsCard .card-body {
  padding: 12px;
}

/* If you want the whole insights section a bit more compact */
#custInsightsCard .card[style*="box-shadow:none"] .card-header {
  font-size: 13px;
}
#custInsightsCard .card[style*="box-shadow:none"] .small {
  font-size: 12px;
}

/* --- Fancy Output Console --- */
.output-card .card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 8px;
}

.output-toolbar{
  display:flex;
  gap: 6px;
  align-items:center;
  flex-wrap: nowrap;
}

.output-toolbar .btn{
  border-radius: 10px;
}

.output-console{
  background: radial-gradient(1200px 600px at 20% 0%, rgba(59,130,246,.18) 0%, rgba(11,18,32,1) 42%) !important;
  color: rgba(226,232,240,.92) !important;
  border: 1px solid rgba(59,130,246,.14);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  padding: 12px 12px 10px;
  height: 260px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.35;
}

.output-line{
  display:flex;
  gap: 10px;
  align-items:flex-start;
  padding: 4px 6px;
  border-radius: 10px;
}
.output-line:hover{
  background: rgba(255,255,255,.04);
}

.output-ts{
  width: 68px;
  flex: 0 0 auto;
  color: rgba(148,163,184,.9);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.output-msg{
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.output-badge{
  width: 58px;
  flex: 0 0 auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  text-align:center;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color: rgba(226,232,240,.92);
}

.output-badge.ok{ background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.22); }
.output-badge.warn{ background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.26); }
.output-badge.err{ background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.26); }
.output-badge.info{ background: rgba(59,130,246,.14); border-color: rgba(59,130,246,.26); }

.output-meta{
  color: rgba(148,163,184,.9);
  font-size: 12px;
  margin-top: 8px;
}

/* Small quick range buttons */
.quick-ranges{
  display:flex;
  gap: 6px;
  align-items:center;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.quick-ranges .btn{
  padding: .25rem .5rem;
  border-radius: 10px;
  font-size: 12px;
}

/* --- Marketing Tabs (pills) --- */
.marketing-tabs .btn-group .btn{
  border-radius: 999px !important;
  padding: .35rem .75rem;
  font-weight: 700;
}
.marketing-tabs .btn-group{
  gap: 8px;
}
.marketing-tabs .btn-outline-secondary{
  border-color: rgba(15,23,42,.12);
  color: rgba(15,23,42,.75);
  background: rgba(248,250,252,.9);
}
.marketing-tabs .btn-outline-secondary:hover{
  background: rgba(37,99,235,.06);
  border-color: rgba(37,99,235,.20);
  color: rgba(15,23,42,.9);
}
.marketing-tabs .btn-primary{
  box-shadow: 0 8px 18px rgba(37,99,235,.22);
}

/* Marketing Header (tabs + range) */
.marketing-header .marketing-tabs .btn{
  border-radius: 999px !important;
  font-weight: 700;
  padding: .35rem .75rem;
}
.marketing-header .marketing-tabs{ gap: 8px; }
.marketing-header .marketing-rangebar{
  white-space: nowrap;
}
.marketing-header .marketing-rangebar .form-control{
  border-radius: 12px;
}

.marketing-rangebar { white-space: nowrap; }
@media (max-width: 1100px){
  .marketing-rangebar { width: 100%; justify-content: flex-end; }
}

/* Quick range buttons active state */
.quick-ranges .btn.active-range{
  background: rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.35);
  color: rgba(15,23,42,.92);
  box-shadow: 0 8px 18px rgba(37,99,235,.16);
}

/* Make KPI cards in a row same height */
.row.kpi-row > [class*="col-"] { display: flex; }
.row.kpi-row > [class*="col-"] > .card { width: 100%; }

/* KPI card body layout */
.card.kpi { height: 100%; }
.card.kpi .card-body{
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

/* optional: keep KPI value stable and prevent wrap ugliness */
.card.kpi .kpi-value,
.card.kpi .kpi-small{
  line-height: 1.05;
}

/* Affiliates Drilldown modal tweaks */
#affDrillRangebar .form-control { height: 32px; }
#affDrillRangebar .btn { height: 32px; }
#affDrillRangebar { flex-wrap: nowrap; }

/* --- Affiliates Drilldown Modal --- */
.aff-modal { border-radius: 16px; }
.aff-modal__header { padding: 16px 18px; border-bottom: 0; }
.aff-modal__title { min-width: 240px; }

.aff-modal__toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 18px 14px;
  border-bottom: 1px solid rgba(15,23,42,.08);
}

.aff-toolbar__left{ display:flex; align-items:center; gap:10px; }
.aff-toolbar__right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:nowrap;
}

.aff-modal__toolbar .form-control{ height:32px; font-size: 13px; max-width: 150px; }
.aff-modal__toolbar .btn{ height:32px; }

.aff-seg .btn{ min-width: 74px; } /* verhindert "Last" Umbruch */

.aff-switch{
  display:flex;
  align-items:center;
  gap:8px;
  margin:0;
  white-space:nowrap;
}
.aff-switch .form-check-input{ margin:0; }
.aff-switch .form-check-label{ font-size: 12px; color:#6b7280; }

@media (max-width: 992px){
  .aff-modal__toolbar{ flex-wrap:wrap; }
  .aff-toolbar__right{ flex-wrap:wrap; justify-content:flex-end; }
  .aff-modal__toolbar .form-control{ max-width: 180px; }
}

