/*
 * Copyright 2018 The Outline Authors
 *
 * 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
 *
 *      http://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.
 */

html {
  background: #efefef;
}

body {
  /*
    We're not properly CSS resetting - this is to prevent
    the browser agent from insetting the main window weirdly.
  */
  margin: 0;
}

:root {
  /* tokens */
  --outline-safe-area-top: 0px;
  --min-supported-device-width: 320px;

  --outline-primary: hsl(170, 60%, 46%);
  --outline-primary-dark: hsl(176, 97%, 26%);
  --outline-primary-rgb: 47, 186, 156;

  --outline-primary-medium: hsl(172, 60%, 72%);
  --outline-primary-light: hsl(174, 58%, 91%);

  /* RGB values for primary color */
  --outline-dark-primary: hsl(200, 19%, 18%);
  --outline-error: hsl(4, 90%, 58%);
  --outline-warning: hsl(52, 100%, 49%);

  --outline-black: hsl(0, 0%, 0%);
  --outline-off-black: hsl(0, 0%, 15%);
  --outline-dark-gray: hsl(213, 5%, 39%);
  --outline-medium-gray: hsl(0, 0%, 45%);
  --outline-light-gray: hsl(0, 0%, 95%);
  --outline-white: hsl(0, 0%, 100%);

  /* New dark mode colors - matching Outline Manager */
  --outline-dark-bg: hsl(203, 19%, 14%);
  /* Dark background from Outline Manager */
  --outline-dark-card: hsl(203, 12%, 22%);
  /* Card background for dark mode */
  --outline-dark-footer: hsl(200, 19%, 18%);
  /* Footer background for dark mode */
  --outline-dark-border: hsl(200, 18%, 26%);
  /* Border color for dark mode */

  --outline-font-family: Roboto, sans-serif;

  --outline-corner: 0.5rem;

  --outline-large-gutter: 2rem;
  --outline-gutter: 1rem;
  --outline-slim-gutter: 0.75rem;
  --outline-mini-gutter: 0.25rem;

  /* theme */
  --outline-card-background: var(--outline-white);
  --outline-card-footer: var(--outline-light-gray);
  --outline-text-color: var(--outline-black);
  --outline-label-color: var(--outline-medium-gray);
  --outline-hairline: 1px solid hsl(0, 0%, 85%);
  --outline-elevation-color: hsla(0, 0%, 0%, 0.10);
  --outline-elevation: var(--outline-elevation-color) 2px 2px 4px 0px;
  --outline-icon-color:rgb(73, 69, 79);

  --outline-partial-connection-color: var(--outline-primary-light);
  --outline-complete-connection-color: var(--outline-primary-medium);

  --outline-comms-dialog-primary-background-color: var(--outline-dark-primary);
  --outline-comms-dialog-primary-text-color: hsl(0, 0%, 87%);
  --outline-comms-dialog-secondary-text-color: rgba(255, 255, 255, 0.54);
  --outline-app-dialog-primary-background-color: var(--outline-white);

  /* Input field colors */
  --outline-input-bg: var(--outline-white);
  --outline-input-text: var(--outline-black);
  --outline-input-border: var(--outline-medium-gray);

  --mdc-typography-font-family: var(--outline-font-family);
  --mdc-theme-primary: var(--outline-primary);

  --md-ref-typeface-brand: 'Jigsaw Sans';
  --md-ref-typeface-plain: var(--outline-font-family);

  /* Style Material inputs */
  --md-dialog-container-color: var(--outline-app-dialog-primary-background-color);
  --md-dialog-headline-color: var(--outline-text-color);
  --md-dialog-supporting-text-color: var(--outline-text-color);
  --md-filled-button-container-color: var(--outline-primary);
  --md-filled-button-label-text-color: var(--outline-text-color);
  --md-filled-text-field-container-color: var(--outline-input-bg);
  --md-filled-text-field-input-text-color: var(--outline-input-text);
  --md-menu-container-color: var(--outline-card-background);
  --md-outlined-text-field-input-text-color: var(--outline-input-text);
  --md-sys-color-background: var(--outline-background-color);
  --md-sys-color-on-surface-variant: var(--outline-text-color);
  --md-sys-color-on-surface: var(--outline-text-color);
  --md-sys-color-outline: var(--outline-input-border);
  --md-sys-color-primary: var(--outline-primary);
  --md-sys-color-surface-container-highest: var(--outline-card-background);
  --md-sys-color-surface-container: var(--outline-card-background);
  --md-sys-color-surface: var(--outline-card-background);
  --md-sys-shape-corner-extra-large: var(--outline-corner);
  --md-sys-shape-corner-large: var(--outline-corner);
  --md-sys-shape-corner-medium: var(--outline-corner);
  --md-text-button-label-text-color: var(--outline-primary);

  /* Style older Material Web Components */
  --mdc-theme-surface: var(--outline-card-background);
  --mdc-theme-on-surface: var(--outline-text-color);
  --mdc-text-field-fill-color: var(--outline-input-bg);
  --mdc-text-field-ink-color: var(--outline-input-text);
  --mdc-text-field-label-ink-color: var(--outline-label-color);
  --mdc-text-field-outlined-idle-border-color: var(--outline-input-border);

  /* default light theme */
  --outline-splash-title-color: var(--outline-primary-dark);
  --outline-background: var(--outline-white);
  --outline-card-background: var(--outline-white);
  --outline-card-footer: var(--outline-light-gray);
  --outline-text-color: var(--outline-black);
  --outline-label-color: var(--outline-medium-gray);
  --outline-hairline: 1px solid hsl(0, 0%, 85%);
  --outline-elevation: rgb(0 0 0 / 30%) 0px 2px 3px 2px;
  --outline-app-dialog-primary-background-color: var(--outline-white);

  /* Input field colors for light mode */
  --outline-input-bg: var(--outline-white);
  --outline-input-text: var(--outline-black);
  --outline-input-border: var(--outline-medium-gray);

  color-scheme: light;
}

/* Safe area inset for iOS notch/status bar - defined once at root level */
@supports (padding-top: constant(safe-area-inset-top)) {
  :root {
    --outline-safe-area-top: constant(safe-area-inset-top);
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  :root {
    --outline-safe-area-top: env(safe-area-inset-top);
  }
}

/* Class-based dark mode - applied when user selects dark theme */
html.dark {
  --outline-error: hsl(4, 90%, 62%);

  --outline-background: var(--outline-dark-bg);
  --outline-card-background: var(--outline-dark-card);
  --outline-card-footer: var(--outline-dark-footer);
  --outline-text-color: var(--outline-white);
  --outline-label-color: hsl(0, 0%, 70%);
  --outline-hairline: 1px solid var(--outline-dark-border);
  --outline-elevation: rgb(0 0 0 / 30%) 0px 2px 3px 2px;
  --outline-comms-dialog-primary-background-color: var(--outline-dark-primary);
  --outline-app-dialog-primary-background-color: var(--outline-dark-card);

  /* Input field colors for dark mode */
  --outline-input-bg: var(--outline-dark-bg);
  --outline-input-text: var(--outline-white);
  --outline-input-border: var(--outline-dark-border);
  --outline-icon-color: var(--outline-label-color);

  color-scheme: dark;
}

/* Style paper and iron inputs from Polymer */
paper-input,
iron-input {
  --paper-input-container-color: var(--outline-input-text);
  --paper-input-container-input-color: var(--outline-input-text);
  --paper-input-container-focus-color: var(--outline-primary);
  --iron-input-container-color: var(--outline-input-text);
  --paper-input-container-shared-input-style_-_color: var(--outline-input-text);
}

/* Add general input styling to ensure proper contrast */
input,
textarea,
select,
md-text-field,
md-filled-text-field,
md-outlined-text-field,
md-textarea,
md-filled-textarea,
md-outlined-textarea,
paper-input,
iron-input {
  background-color: var(--outline-input-bg);
  color: var(--outline-input-text);
  border: 1px solid var(--outline-input-border);
}

/* Style Material Web Components textfields */
mwc-textfield {
  --mdc-text-field-fill-color: var(--outline-input-bg);
  --mdc-text-field-ink-color: var(--outline-input-text);
  --mdc-text-field-label-ink-color: var(--outline-label-color);
  --mdc-text-field-outlined-idle-border-color: var(--outline-input-border);
  --mdc-theme-primary: var(--outline-primary);
}

/* Fix for language selector */
language-view {
  color: var(--outline-text-color);
  background-color: var(--outline-background);
}

/* Force text colors for specific elements */
* {
  color-scheme: normal;
}

/* Set default text color for all pages */
html,
body {
  color: var(--outline-text-color);
  background-color: var(--outline-background);
}

@font-face {
  font-family: 'Jigsaw Sans';
  font-style: normal;
  font-weight: 500;
  src: url(./assets/jigsaw_sans_medium.woff2) format('woff2');
}

@font-face {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: normal;
  src: url(./assets/material_icons.woff2) format('woff2');
}

/* This is specifically the icon font <md-icon> looks for. */
@font-face {
  font-family: 'Material Symbols Outlined';
  font-style: normal;
  font-weight: normal;
  src: url(./assets/material_icons.woff2) format('woff2');
}

/* Material icons styling - consider moving to a component-specific file if only used in certain components */
.material-icons {
  -webkit-font-smoothing: antialiased;
  direction: ltr;
  display: inline-block;
  font-family: 'Material Icons';
  font-size: 1.5rem;
  font-style: normal;
  font-weight: normal;
  letter-spacing: normal;
  line-height: 1;
  text-rendering: optimizeLegibility;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
}

/* Ensure that all footer text is visible in all themes */
footer,
h1,
h2,
section,
.zerostate-footer {
  color: var(--outline-text-color);
}
