/* /public/css/report.css */
/* Premium UI/UX v7 (DARK FIX + GLOBAL OVERRIDE) - report tab only */

/* ==========================================================================
   DARK tokens only (SCOPED to #report.report-panel)
   - Report tab is ALWAYS dark
   ========================================================================== */

#report.report-panel{
  --rp-pad: 14px;
  --rp-gap: 12px;
  --rp-gap-lg: 16px;

  --rp-bg: #070b14;
  --rp-surface: rgba(255,255,255,0.06);
  --rp-surface2: rgba(255,255,255,0.04);
  --rp-surface3: rgba(255,255,255,0.03);

  --rp-border: rgba(255,255,255,0.12);
  --rp-border2: rgba(255,255,255,0.08);

  --rp-text: rgba(255,255,255,0.92);
  --rp-muted: rgba(255,255,255,0.56);

  --rp-accent: #2563eb;
  --rp-accent2: #7c3aed;
  --rp-danger: #ef4444;

  --rp-radius: 20px;
  --rp-radius-md: 16px;
  --rp-radius-sm: 12px;

  --rp-shadow: 0 26px 70px rgba(0,0,0,0.54);
  --rp-shadow2: 0 14px 34px rgba(0,0,0,0.42);
  --rp-shadow3: 0 18px 46px rgba(0,0,0,0.52);

  --rp-inset: inset 0 1px 0 rgba(255,255,255,0.06);
  --rp-ring: rgba(37,99,235,0.20);

  --rp-font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;

  /* ✅ native controls hint */
  color-scheme: dark;
}

/* ✅ even if site theme is light, report tab stays DARK */
html[data-theme="light"] #report.report-panel,
body.theme-light #report.report-panel,
#report.report-panel[data-theme="light"]{
  color-scheme: dark;
}

/* ==========================================================================
   HARD OVERRIDE (fix: white blocks + black text from global css)
   ========================================================================== */

#report.report-panel{
  background-color: var(--rp-bg) !important;
  color: var(--rp-text) !important;
}

/* wrapper가 흰 배경 먹는 케이스 제거 */
#report.report-panel :where(.report-layout, .report-aside, .report-main){
  background: transparent !important;
}

/* 전역에서 p/span/div 등에 검정색 먹는 케이스 강제 교정 */
#report.report-panel :where(p,span,div,li,dt,dd,label,small,em,strong,b,code,pre){
  color: inherit;
}

/* "label/muted/small" 류는 무조건 muted */
#report.report-panel :where(.label,.muted,small,.report-head__desc,.report-history__hint,.report-form__meta,.date,.history-chip__ago){
  color: var(--rp-muted) !important;
}

/* 전역에서 카드/패널에 흰 배경 넣는 경우 차단 (report 내부 한정) */
#report.report-panel :where(.panel,.card,.card-body,.list-group-item,.well,.box){
  background: transparent !important;
}

/* ==========================================================================
   Base panel
   ========================================================================== */

#report.report-panel{
  font-family: var(--rp-font);
  padding: var(--rp-pad);
  border-radius: var(--rp-radius);
  max-width: 100%;
  margin: 0 auto;

  position: relative;
  overflow: hidden;

  background:
    radial-gradient(1200px 480px at 12% 0%, rgba(37,99,235,0.14), transparent 62%),
    radial-gradient(900px 420px at 88% 12%, rgba(124,58,237,0.13), transparent 58%),
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 30%),
    var(--rp-bg) !important;

  border: 1px solid var(--rp-border) !important;
  box-shadow: var(--rp-shadow);
}

#report.report-panel::before{
  content:"";
  position:absolute;
  inset:-2px;
  pointer-events:none;
  opacity: .10;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.10) 0px,
      rgba(255,255,255,0.10) 1px,
      transparent 1px,
      transparent 34px
    );
}

#report.report-panel::after{
  content:"";
  position:absolute;
  inset:-60px;
  pointer-events:none;
  opacity: .55;
  background:
    radial-gradient(900px 520px at 50% -10%, rgba(255,255,255,0.05), transparent 62%),
    radial-gradient(900px 520px at 50% 110%, rgba(0,0,0,0.28), transparent 62%);
}

#report.report-panel > *{ position: relative; z-index: 1; }

@media (min-width: 961px){
  #report.report-panel{
    --rp-pad: 22px;
    --rp-gap: 14px;
    --rp-gap-lg: 16px;
    max-width: 1320px;
  }
}

@supports ((-webkit-backdrop-filter: blur(14px)) or (backdrop-filter: blur(14px))){
  #report .report-history,
  #report .report-toolbar,
  #report .report-summary,
  #report .report-card,
  #report .report-block,
  #report .report-help{
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
}

/* ==========================================================================
   Header
   ========================================================================== */

#report .report-head{
  display:grid;
  grid-template-columns: 1fr auto;
  gap: var(--rp-gap);
  align-items: start;
  margin-bottom: 0;
  position: relative;
  z-index: 3; /* ✅ 위에 잘리는 케이스 방지 */
}

#report .report-head__title h3{
  margin:0;
  font-size: 20px;
  font-weight: 1000;
  letter-spacing: -0.4px;
  color: var(--rp-text) !important;
}

#report .report-head__desc{
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

#report .report-head__actions{
  display:flex;
  justify-content:flex-end;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 960px){
  #report .report-head{ grid-template-columns: 1fr; }
  #report .report-head__actions{ justify-content: flex-start; }
}

/* ==========================================================================
   Layout split (aside + main)
   ========================================================================== */

#report .report-layout{
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--rp-gap);
  margin-top: var(--rp-gap);
}

#report .report-aside,
#report .report-main{ min-width: 0; }

@media (min-width: 961px){
  #report .report-layout{
    grid-template-columns: 420px 1fr;
    align-items: start;
    gap: var(--rp-gap-lg);
  }
  #report .report-aside{
    position: sticky;
    top: 16px;
    align-self: start;
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

#report .btn-ghost{
  border: 1px solid var(--rp-border) !important;
  background: linear-gradient(180deg, var(--rp-surface), var(--rp-surface2)) !important;
  color: var(--rp-muted) !important;
  padding: 10px 14px;
  border-radius: 999px;
  cursor:pointer;
  transition: transform .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, filter .15s ease;
  box-shadow: var(--rp-shadow2), var(--rp-inset);
  font-weight: 900;
  letter-spacing: -0.1px;
}

#report .btn-ghost:disabled{
  opacity: 0.55;
  cursor:not-allowed;
  transform:none;
  box-shadow:none;
}

@media (hover: hover) and (pointer: fine){
  #report .btn-ghost:hover{
    color: var(--rp-text) !important;
    border-color: rgba(37,99,235,0.32) !important;
    transform: translateY(-1px);
    filter: saturate(1.06);
  }
}

/* ==========================================================================
   History / Help (fix: white background + black text)
   ========================================================================== */

#report .report-history,
#report .report-help{
  background: linear-gradient(180deg, var(--rp-surface), var(--rp-surface2)) !important;
  border: 1px solid var(--rp-border) !important;
  border-radius: var(--rp-radius);
  padding: 14px;
  box-shadow: var(--rp-shadow2), var(--rp-inset);
  position: relative;
  overflow: hidden;
  color: var(--rp-text) !important;
}

#report .report-history{ margin-bottom: var(--rp-gap); }

#report .report-history::before,
#report .report-help::before{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(37,99,235,0.22), rgba(124,58,237,0.16), rgba(255,255,255,0));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events:none;
  opacity: .65;
}

#report .report-history__top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 10px;
  gap: 10px;
}

#report .report-history__label{
  font-weight: 1000;
  font-size: 13px;
  letter-spacing: -0.2px;
  color: var(--rp-text) !important;
}

#report .report-history__hint{
  font-size: 12px;
}

#report .report-history__list{
  display:flex;
  flex-wrap:wrap;
  gap: 10px;
}

@media (max-width: 960px){
  #report .report-history__list{
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  #report .report-history__list::-webkit-scrollbar{ height: 6px; }
  #report .report-history__list::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,0.16);
    border-radius: 999px;
  }
}

#report .history-chip{
  display:inline-flex;
  align-items:center;
  gap:10px;
  max-width:100%;
  border: 1px solid var(--rp-border2) !important;
  background: linear-gradient(180deg, var(--rp-surface2), var(--rp-surface3)) !important;
  color: var(--rp-text) !important;
  padding: 10px 12px;
  border-radius: 999px;
  cursor:pointer;
  transition: transform .15s ease, border-color .15s ease, filter .15s ease;
  box-shadow: var(--rp-shadow2), var(--rp-inset);
  flex: 0 0 auto;
}

@media (hover: hover) and (pointer: fine){
  #report .history-chip:hover{
    transform: translateY(-1px);
    border-color: rgba(37,99,235,0.30) !important;
    filter: saturate(1.05);
  }
}

#report .history-chip__dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--rp-accent), var(--rp-accent2));
  box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

#report .history-chip__id{
  font-weight: 1000;
  font-size: 12px;
  max-width: 360px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color: var(--rp-text) !important;
}

#report .history-chip__x{
  font-size: 18px;
  line-height: 1;
  color: rgba(255,255,255,0.45) !important;
  padding: 0 2px;
}
#report .history-chip__x:hover{ color: var(--rp-danger) !important; }

#report .report-help__title{
  font-weight: 1000;
  font-size: 13px;
  letter-spacing: -0.2px;
  margin-bottom: 8px;
  color: var(--rp-text) !important;
}

#report .report-help__list{
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--rp-muted) !important;
}

#report .kbd{
  display:inline-block;
  border: 1px solid var(--rp-border) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.05)) !important;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  margin-right: 6px;
  box-shadow: var(--rp-inset);
  color: var(--rp-text) !important;
}

/* ==========================================================================
   Form
   ========================================================================== */

#report .report-form__row{
  display:flex;
  gap: 12px;
  align-items:center;
}

#report .report-input{
  flex:1;
  height: 52px;
  border-radius: 18px;
  border: 1px solid var(--rp-border) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.04)) !important;
  color: var(--rp-text) !important;
  padding: 0 16px;
  outline:none;
  transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
  box-shadow: var(--rp-inset);
  font-weight: 800;
}

#report .report-input::placeholder{
  color: rgba(255,255,255,0.40);
}

#report .report-input:focus{
  border-color: rgba(37,99,235,0.48) !important;
  box-shadow: 0 0 0 4px var(--rp-ring), var(--rp-inset);
  transform: translateY(-1px);
}

#report .report-submit,
#report button.submit{
  height: 52px;
  padding: 0 22px;
  border-radius: 18px;
  border: 1px solid rgba(37,99,235,0.34) !important;
  background: linear-gradient(135deg, rgba(37,99,235,0.98), rgba(124,58,237,0.92)) !important;
  color: #fff !important;
  font-weight: 1000;
  letter-spacing: -0.2px;
  cursor:pointer;
  box-shadow: 0 18px 44px rgba(37,99,235,0.22);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

@media (hover: hover) and (pointer: fine){
  #report .report-submit:hover,
  #report button.submit:hover{
    transform: translateY(-1px);
    box-shadow: 0 22px 54px rgba(37,99,235,0.28);
    filter: saturate(1.08);
  }
}

#report .report-submit:disabled{ opacity: .6; cursor:not-allowed; transform:none; }

@media (max-width: 960px){
  #report .report-form__row{
    flex-direction: column;
    align-items: stretch;
  }
  #report .report-submit,
  #report button.submit{ width: 100%; }
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

#report .report-toolbar{
  margin-top: var(--rp-gap);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 18px;
  border: 1px solid var(--rp-border) !important;
  background: linear-gradient(180deg, var(--rp-surface), var(--rp-surface2)) !important;
  box-shadow: var(--rp-shadow2), var(--rp-inset);
  flex-wrap: wrap;
  color: var(--rp-text) !important;
}

#report .report-toolbar__left,
#report .report-toolbar__right{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}

#report .tool{
  display:flex;
  align-items:center;
  gap: 10px;
}

#report .tool__label{
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: -0.1px;
  color: var(--rp-muted) !important;
}

#report .tool__select{
  height: 42px;
  border-radius: 16px;
  border: 1px solid var(--rp-border) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.04)) !important;
  padding: 0 12px;
  color: var(--rp-text) !important;
  outline: none;
  box-shadow: var(--rp-inset);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  font-weight: 900;
}

#report .tool__select:focus{
  border-color: rgba(37,99,235,0.45) !important;
  box-shadow: 0 0 0 4px var(--rp-ring), var(--rp-inset);
  transform: translateY(-1px);
}

@media (max-width: 960px){
  #report .report-toolbar{
    flex-direction: column;
    align-items: stretch;
  }
  #report .report-toolbar__left,
  #report .report-toolbar__right{
    justify-content: space-between;
    width: 100%;
  }
  #report .tool{
    width: 100%;
    justify-content: space-between;
  }
  #report .tool__select{
    width: 60%;
  }
}

/* ==========================================================================
   State + Result base
   ========================================================================== */

#report .report-state{
  margin-top: var(--rp-gap);
  display:inline-flex;
  align-items:center;
  gap: 10px;
  font-size: 13px;
  color: var(--rp-muted) !important;
}

#report .spinner{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(37,99,235,0.20);
  border-top-color: rgba(37,99,235,0.90);
  animation: rp_spin .9s linear infinite;
}
@keyframes rp_spin{ to{ transform: rotate(360deg);} }

#report .report-result{
  margin-top: var(--rp-gap);
  display: grid;
  gap: var(--rp-gap);
  color: var(--rp-text) !important;
}

#report .report-result :where(h1,h2,h3,h4,h5,p,ul,ol){ margin: 0; }
#report .report-result p{ line-height: 1.65; color: var(--rp-text) !important; }

/* ==========================================================================
   Result: Summary / KPI
   ========================================================================== */

#report .report-result :where(.report-summary, .summary, .result-summary, .report-kpi){
  display:flex;
  justify-content:space-between;
  gap: 14px;
  align-items:center;

  background: linear-gradient(180deg, var(--rp-surface), var(--rp-surface2)) !important;
  border: 1px solid var(--rp-border) !important;
  border-radius: var(--rp-radius);
  padding: 14px 14px;
  box-shadow: var(--rp-shadow2), var(--rp-inset);
  position: relative;
  overflow: hidden;
  color: var(--rp-text) !important;
}

#report .report-result :where(.report-summary, .summary, .result-summary, .report-kpi)::before{
  content:"";
  position:absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(180deg, rgba(37,99,235,0.95), rgba(124,58,237,0.92));
  opacity: .65;
}

#report .report-result :where(.report-summary, .summary, .result-summary, .report-kpi)::after{
  content:"";
  position:absolute;
  inset:-2px;
  background:
    radial-gradient(900px 260px at 12% 0%, rgba(37,99,235,0.18), transparent 62%),
    radial-gradient(800px 260px at 88% 20%, rgba(124,58,237,0.16), transparent 62%);
  pointer-events:none;
  opacity: .85;
}

#report .meta-pill{
  display:inline-flex;
  gap: 6px;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--rp-border2) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.04)) !important;
  font-size: 12px;
  color: var(--rp-muted) !important;
  box-shadow: var(--rp-inset);
  font-weight: 900;
}

@media (max-width: 960px){
  #report .report-result :where(.report-summary, .summary, .result-summary, .report-kpi){
    flex-direction: column;
    align-items: stretch;
  }
}

/* ==========================================================================
   Result: Copy button fallback
   ========================================================================== */

#report .report-result :where(button, .icon-btn, .copy-btn, .btn-copy){
  border: 1px solid var(--rp-border2) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.05)) !important;
  color: var(--rp-muted) !important;
  padding: 7px 10px;
  border-radius: 12px;
  cursor:pointer;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.1px;
  box-shadow: var(--rp-inset);
  transition: transform .15s ease, border-color .15s ease, color .15s ease, filter .15s ease;
}

@media (hover: hover) and (pointer: fine){
  #report .report-result :where(button, .icon-btn, .copy-btn, .btn-copy):hover{
    color: var(--rp-text) !important;
    border-color: rgba(37,99,235,0.30) !important;
    transform: translateY(-1px);
    filter: saturate(1.06);
  }
}

/* ==========================================================================
   Result: Grid + Card
   ========================================================================== */

#report .report-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: var(--rp-gap);
}

@media (min-width: 961px){
  #report .report-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--rp-gap-lg);
  }
}

#report .report-card{
  position: relative;
  background: linear-gradient(180deg, var(--rp-surface), var(--rp-surface2)) !important;
  border: 1px solid var(--rp-border) !important;
  border-radius: var(--rp-radius);
  padding: 14px;
  box-shadow: var(--rp-shadow2), var(--rp-inset);
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, filter .15s ease;
  color: var(--rp-text) !important;
}

#report .report-card::before{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(37,99,235,0.28), rgba(124,58,237,0.20), rgba(255,255,255,0));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: .65;
  pointer-events:none;
}

#report .report-card::after{
  content:"";
  position:absolute;
  left: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(37,99,235,0.14), transparent 62%);
  opacity: .85;
  pointer-events:none;
}

@media (hover: hover) and (pointer: fine){
  #report .report-card:hover{
    transform: translateY(-2px);
    border-color: rgba(37,99,235,0.26) !important;
    box-shadow: var(--rp-shadow3), var(--rp-inset);
    filter: saturate(1.04);
  }
}

#report .badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--rp-border2) !important;
  background: linear-gradient(180deg, rgba(37,99,235,0.12), rgba(124,58,237,0.08)) !important;
  color: var(--rp-text) !important;
  font-weight: 1000;
  font-size: 12px;
  box-shadow: var(--rp-inset);
}

/* ==========================================================================
   Toast + Reduced motion
   ========================================================================== */

.report-toast{
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(2,6,23,0.86);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
  padding: 10px 12px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  font-size: 12px;
  z-index: 9999;
}

.report-toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce){
  #report *{
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
