/*
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

  html {
    scroll-behavior: smooth;
  }

  body {
    font: 18px/1.5 system-ui, sans-serif;
    margin: 0;
    --accent: #1c6ef3;
  }

  strong {
    font-weight: 600;
  }

  svg {
    fill: currentColor;
    vertical-align: bottom;
  }

  a {
    color: var(--accent);
  }
}

@layer components {
  /*
   * Container
   * ----------------------------------------------------------------------- */

   .Container {
    max-width: 48rem;
    margin: 0 auto;
    padding: 0 1em;
  }

  /*
   * Header
   * ----------------------------------------------------------------------- */

   .Header {
    background: #f8f8f8;
    padding: 2rem 2rem 3rem;
    text-align: center;
  }

  .Header-title {
    font-size: 2.5rem;
    font-weight: 300;
    margin: 2rem 0;
    line-height: 1.1;
    text-align: center;
    text-wrap-style: balance;
  }

  .Header-logo {
    width: 80px;
    aspect-ratio: 9 / 5;
  }

  .Header-subTitle {
    text-wrap-style: balance;
  }

  @media (min-width: 768px) {
    .Header-title {
      display: flex;
      place-content: center;
    }
    .Header-titlePrefix {
      border-right: 1px solid #ccc;
      margin-right: 1rem;
      padding-right: 1rem;
    }
  }

  /*
   * Footer
   * ----------------------------------------------------------------------- */

   .Footer {
    background: #f8f8f8;
    display: flow-root;
    padding-top: 3rem;
  }

  /*
   * Instructions
   * ----------------------------------------------------------------------- */

   .Instructions {
    contain: paint;
    padding-left: 2em;
  }

  .Instructions-item {
    margin-bottom: 1rem;
    padding: 0 0 1rem .5rem;
    position: relative;
  }

  .Instructions-item::marker {
    font-weight: bold;
  }

  .Instructions-item::before {
    content: '';
    position: absolute;
    background: #ddd;
    height: 1px;
    bottom: 0px;
    left: -2em;
    right: -2em;
  }

  .Instructions-term {
    color: #333;
    background: #ffc;
    padding: 2px 5px;
    font-style: normal;
  }

  .Instructions-icon {
    background: #ddd;
    border-radius: 50%;
    outline: 2px solid #ddd;
    margin: 0 4px;
    padding: 2px;
    width: 1.333em;
    height: 1.333em;
    vertical-align: -4px;
  }

  /*
   * SubHeading
   * ----------------------------------------------------------------------- */

   .SubHeading {
    font-size: 1.667rem;
    font-weight: 300;
    margin: 3rem 0 2rem;
    text-align: center;
  }

  .SubHeading--flat {
    margin-top: 0;
  }

  /*
   * Note
   * ----------------------------------------------------------------------- */

   .Note {
    color: #777;
    font-size: 0.9em;
    font-style: italic;
    margin: 1.5em auto 4rem;
    max-width: 90%;
    text-align: center;
    text-wrap-style: balance;
  }

  .Note-subHead {
    margin: 0 auto 2rem;
  }

  /*
   * Importer
   * ----------------------------------------------------------------------- */

   .Importer {
    border: 3px dashed #ccc;
    border-radius: 8px;
    color: #888;
    cursor: pointer;
    display: block;
    padding: 3em;
    text-align: center;
    transition: border-color 0.2s ease, background-color 0.2s ease;
  }

  .Importer-icon {
    width: 1.5em;
    height: 1.5em;
  }

  .Importer--active {
    border-color: var(--accent);
    background-color: color-mix(in hsl, var(--accent), transparent 93%);
    color: var(--accent);
  }

  /*
   * Steps
   * ----------------------------------------------------------------------- */

   .Steps {
    display: grid;
    grid-template-columns: auto auto;
    margin-bottom: 4rem;
    place-content: center;
  }

  .Steps-name,
  .Steps-desc {
    margin: 0;
    padding: .75em;
    border-bottom: 1px solid #ddd;
  }

  .Steps-name {
    font-weight: bold;
    padding-right: 0;
  }

  /*
   * ReportSection
   * ----------------------------------------------------------------------- */

   .ReportSection {
    padding: 1em;
    margin: -1em;
    border-radius: .5em;
  }

  /*
   * Report
   * ----------------------------------------------------------------------- */

   .Report {
    border-collapse: collapse;
    margin-top: 1.5rem;
    width: 100%;
  }

  .Report-meta {
    margin-top: -1rem;
    font-size: 0.9em;
    font-style: italic;
    text-align: center;
  }

  .Report-table {
    border-collapse: collapse;
    margin-top: 1.5rem;
    table-layout: fixed;
    width: 100%;
  }

  .Report-table th,
  .Report-table td {
    border: 1px solid #ccc;
    padding: 0.5rem 1rem;
    text-align: left;
    vertical-align: top;
  }

  .Report-table th {
    background-color: #eee;
    border-bottom: 2px solid #000;
    font-weight: bold;
  }

  .Report-table th:last-child,
  .Report-table td:last-child {
    text-align: right;
  }

  .Report-table td:last-child {
    background-repeat: no-repeat;
    background-size: 10000% 100%;
    background-image: linear-gradient(to left,
      hsl(150deg 70% 45%) 0%,
      hsl(45 100% 85%) 10%,
      hsl(0deg 100% 65%));
    background-position-x: var(--percent);
  }

  .Report-break td {
    border-top: 2px solid #000;
  }

  /*
   * Video
   * ----------------------------------------------------------------------- */

  .Video {
    margin: 2em 0;
  }

  .Video iframe {
    border: 1px solid #ccc;
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  /*
   * AuthSection
   * ----------------------------------------------------------------------- */

  .AuthSection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 2rem auto;
  }

  #auth-status {
    margin-bottom: 0;
  }

  .Button {
    background-color: var(--accent);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75em 1.5em;
    text-align: center;
    transition: background-color 0.2s ease;
  }

  .Button:hover {
    background-color: color-mix(in hsl, var(--accent), black 15%);
  }

  .Button:active {
    background-color: color-mix(in hsl, var(--accent), black 30%);
  }

  .Select {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #333;
    font-size: 1rem;
    padding: 0.5em;
    width: 100%;
    max-width: 300px;
    margin-top: 0.5rem;
  }

  /* State Management */
  .AuthSection #auth-status,
  .AuthSection .PropertyFlowSelector,
  .AuthSection .Select,
  .AuthSection #generate-report-button,
  .AuthSection #signout-button {
    display: none;
  }

  .AuthSection.has-error #auth-status,
  .AuthSection.is-loading #auth-status,
  .AuthSection.is-connected #auth-status {
    display: block;
  }

  .AuthSection.has-properties .PropertyFlowSelector {
    display: grid;
  }

  .AuthSection.has-properties .Select,
  .AuthSection.has-properties #generate-report-button {
    display: block;
  }

  .AuthSection.is-connected #auth-button {
    display: none;
  }

  .AuthSection.is-connected #signout-button {
    display: inline-flex;
  }

  /*
   * GoogleButton
   * ----------------------------------------------------------------------- */

  .GoogleButton {
    background-color: #fff;
    border: 1px solid #dadce0;
    border-radius: 4px;
    color: #3c4043;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 500;
    height: 40px;
    padding: 0 12px;
    text-align: center;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
  }

  .GoogleButton:hover {
    background-color: #f8f9fa;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
  }

  .GoogleButton:active {
    background-color: #f1f3f4;
  }

  .GoogleButton-logo {
    width: 18px;
    height: 18px;
  }

  /*
   * PropertyFlowSelector
   * ----------------------------------------------------------------------- */

  .PropertyFlowSelector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid #dadce0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    width: 100%;
    max-width: 800px;
    margin-top: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  }

  .Pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #dadce0;
    height: 400px;
  }

  .Pane:last-child {
    border-right: none;
  }

  .PaneHeader {
    padding: 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dadce0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .PaneTitle {
    font-weight: 600;
    color: #3c4043;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .SearchBox {
    position: relative;
    display: flex;
    align-items: center;
  }

  .SearchIcon {
    position: absolute;
    left: 8px;
    width: 16px;
    height: 16px;
    fill: #7f868d;
    pointer-events: none;
  }

  .SearchInput {
    width: 100%;
    padding: 6px 12px 6px 32px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
  }

  .SearchInput:focus {
    border-color: var(--accent);
  }

  .SelectorList {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
  }

  .SelectorListItem {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .SelectorListItem:hover,
  .SelectorListItem:focus {
    background-color: #f8f9fa;
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .SelectorListItem.is-selected {
    background-color: color-mix(in hsl, var(--accent), transparent 90%);
    border-left: 4px solid var(--accent);
    padding-left: calc(1rem - 4px);
  }

  .SelectorListItem-title {
    font-weight: 500;
    color: #3c4043;
    font-size: 0.95rem;
  }

  .SelectorListItem-subtitle {
    font-size: 0.8rem;
    color: #7f868d;
  }
}
