/**
 * Base styles, layout grid and typography for AI Compliance Bot
 * Exact 1:1 replica of Streamlit's base typography, layout insets, and form controls.
 */

:root {
  /* Streamlit resolves `font = "sans serif"` (.streamlit/config.toml) to these
     exact stacks via its `genericFonts` theme entry. Matching them is what makes
     glyph shapes, metrics and optical weight line up with the Streamlit build
     instead of merely resembling it. */
  --font-family: "Source Sans", sans-serif;
  --font-mono: "Source Code Pro", monospace;
  --font-serif: "Source Serif", serif;
  --font-icon: "Material Symbols Rounded";

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

html {
  min-height: 100vh;
  background-color: var(--product-page);
}

/* Mirrors the .stApp rule: the page is not flat, it carries a single accent
   aura anchored to the top-right corner. Without it every screen reads colder
   and flatter than the Streamlit build. */
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% 0%, var(--product-accent-aura1), transparent 28rem),
    var(--product-page);
  background-attachment: fixed;
  color: var(--product-ink);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Material Symbols Outlined Icon Standard Rules */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded' !important;
  font-weight: normal;
  font-style: normal;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--product-border) 80%, var(--product-ink) 20%);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--product-muted);
}

/* Typography.
   Weights come from Streamlit's own theme (`fontWeights`): h1 700 and h2-h6
   600. inject_product_styles() overrides only size, letter-spacing and
   line-height for h2-h4 and leaves the weights alone, so this must too -
   heavier weights here were reading as a different typeface. */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
  color: var(--product-ink);
  line-height: 1.2;
}

/* Bare h1 is never restyled by the source, so it keeps Streamlit's default
   heading metrics. Page titles go through .product-hero h1 instead. */
h1 {
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: var(--product-type-section);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

h3 {
  font-size: var(--product-type-subsection);
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.25;
  margin-bottom: 0.25rem;
}

h4 {
  font-size: var(--product-type-minor);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

h5 {
  font-size: 1.25rem;
  font-weight: 600;
}

h6 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  font-size: var(--product-type-body);
  color: var(--product-muted);
  line-height: 1.6;
}

a {
  color: var(--product-accent);
  text-decoration: none;
  transition: color var(--motion-micro) var(--ease-micro);
}

a:hover {
  text-decoration: underline;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

code {
  padding: 0.15rem 0.35rem;
  border-radius: 0.35rem;
  background: var(--product-soft);
  border: 1px solid var(--product-border);
  color: var(--product-ink);
}

pre {
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  background: var(--product-soft);
  border: 1px solid var(--product-border);
  overflow-x: auto;
}

/* Layout Containers & Streamlit Insets */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-layout {
  display: flex;
  flex: 1;
  min-height: 100vh;
  position: relative;
}

/* The portal shell reproduces Streamlit's geometry:
     .block-container                     max-width 1380px, padding 2rem / 4rem
     .block-container:has(.portal-layout-marker)
                                          width calc(100% - 1.5rem),
                                          max-width 1400px, centred,
                                          padding-top 4.15rem
     [data-testid="stSidebar"]             18rem (min 17rem / max 19rem)
   The sidebar is a layout sibling in Streamlit rather than an overlay, so the
   content column is centred in the space beside it - not pinned to a fixed
   left margin. */
.main-content {
  flex: 1;
  min-width: 0;
  width: calc(100% - 1.5rem);
  max-width: var(--product-shell-max);
  margin-left: auto;
  margin-right: auto;
  padding:
    var(--product-shell-top)
    var(--product-shell-inset)
    var(--product-shell-bottom);
  box-sizing: border-box;
  transition: padding var(--motion-standard) var(--ease-standard);
}

body.has-portal-layout .main-layout {
  align-items: flex-start;
}

/* The hero keeps the 2rem page inset. Every following page section receives
   another 2rem, producing the 4rem content inset on each side that the
   Streamlit build has - the hero is deliberately wider than the body under it.
   Source rule:
     .block-container [data-testid="stVerticalBlock"]:has(> ... .product-hero)
     > [data-testid="stElementContainer"]:has(.product-hero) ~ * */
.main-content .product-hero ~ * {
  width: calc(100% - 4rem);
  margin-left: 2rem;
  margin-right: 2rem;
}

@media (max-width: 900px) {
  .main-content {
    width: calc(100% - 1.5rem);
    padding-right: 1rem;
    padding-left: 1rem;
  }

  /* Narrow screens drop the extra inset and go edge to edge. */
  .main-content .product-hero ~ * {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

body:not(.has-portal-layout) .main-content-full {
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0;
}


/* Streamlit Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 680;
  line-height: 1.25;
  border-radius: 0.65rem;
  min-height: 2.65rem;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--motion-micro) var(--ease-micro);
}

.btn-primary {
  background: linear-gradient(135deg, var(--product-btn-primary-start) 0%, var(--product-btn-primary-end) 100%) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 0.4rem 1rem var(--product-accent-glow), var(--glass-sheen) !important;
}

.btn-primary * {
  color: #ffffff !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--product-btn-primary-hover-start) 0%, var(--product-btn-primary-hover-end) 100%) !important;
  box-shadow: 0 0.5rem 1.25rem var(--product-accent-glow) !important;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--product-control-bg) !important;
  border: 1px solid var(--product-border) !important;
  border-radius: 0.65rem !important;
  color: var(--product-ink) !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.05) !important;
}

.btn-secondary:hover {
  background: var(--product-control-hover) !important;
  border-color: color-mix(in srgb, var(--product-accent) 55%, var(--product-border) 45%) !important;
  color: var(--product-accent) !important;
  box-shadow: 0 0.25rem 0.75rem color-mix(in srgb, var(--product-accent) 15%, transparent) !important;
  transform: translateY(-1px) !important;
}

.btn-danger {
  background: color-mix(in srgb, var(--product-danger) 10%, var(--product-surface));
  color: var(--product-danger);
  border: 1px solid color-mix(in srgb, var(--product-danger) 35%, transparent);
}

.btn-danger:hover {
  background: var(--product-danger);
  color: #ffffff;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  background: var(--product-soft) !important;
  border-color: var(--product-border) !important;
  color: var(--product-muted) !important;
  box-shadow: none !important;
  opacity: 0.72;
  cursor: not-allowed;
  transform: none !important;
}

/* Streamlit Forms, Inputs & Textareas */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.15rem;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 550;
  color: var(--product-ink);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.62rem 0.88rem;
  font-family: var(--font-family);
  font-size: 0.88rem;
  color: var(--product-ink);
  background-color: var(--product-control-bg);
  border: 1px solid color-mix(in srgb, var(--product-accent) 24%, var(--product-border) 76%);
  border-radius: 0.7rem;
  box-shadow: 0 0.16rem 0.48rem rgba(15, 23, 42, 0.05);
  outline: none;
  transition:
    border-color var(--motion-micro) var(--ease-micro),
    box-shadow var(--motion-micro) var(--ease-micro),
    background-color var(--motion-micro) var(--ease-micro);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: color-mix(in srgb, var(--product-muted) 85%, transparent);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: color-mix(in srgb, var(--product-accent) 58%, var(--product-border) 42%);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--product-accent) 14%, transparent);
}

.form-textarea {
  min-height: 5.8rem;
  resize: vertical;
  line-height: 1.5;
}

.form-help {
  font-size: 0.76rem;
  color: var(--product-muted);
  line-height: 1.45;
  margin-top: 0.15rem;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Containers / Bordered Wrappers */
.product-panel {
  background: var(--glass-panel);
  border: 1px solid var(--product-border);
  border-radius: 1rem;
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.35rem;
}

.product-container-bordered {
  border: 1px solid var(--product-border);
  border-radius: 0.85rem;
  background: var(--product-surface);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.35rem;
  box-shadow: 0 0.12rem 0.4rem rgba(15, 23, 42, 0.025);
}

/* Animations */
.animate-fade-in {
  animation: fadeIn var(--motion-standard) var(--ease-standard) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
