@import url('./light-theme.css');
@import url('./dark-theme.css');

/* Shared typography and basic design tokens */
:root {
  /* Font families */
  --font-sans: "Source Sans 3",Red Hat Display,Roboto,"sans-serif";

  /* Font sizes (rem) and line heights */
  --fs-900: 2rem;    /* 32px */
  --fs-800: 1.75rem; /* 28px */
  --fs-700: 1.5rem;  /* 24px */
  --fs-600: 1.25rem; /* 20px */
  --fs-500: 1.125rem;/* 18px */
  --fs-400: 1rem;    /* 16px */
  --fs-300: 0.875rem;/* 14px */
  --fs-200: 0.75rem; /* 12px */

  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-loose: 1.7;

  /* Font weight scale */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
}

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-400);
  line-height: var(--lh-normal);
  color: var(--theme-color-foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings */
h1, h2, h3, h4, h5, h6 { font-weight: var(--fw-semibold); margin: 0 0 0.5em; line-height: var(--lh-tight); }
h1 { font-size: var(--fs-900); }
h2 { font-size: var(--fs-800); }
h3 { font-size: var(--fs-700); }
h4 { font-size: var(--fs-600); }
h5 { font-size: var(--fs-500); }
h6 { font-size: var(--fs-400); }

/* Paragraphs and small text */
p { margin: 0 0 1em; }
small, .text-xs { font-size: var(--fs-200); line-height: 1.4; }
.text-sm { font-size: var(--fs-300); }
.text-base { font-size: var(--fs-400); }
.text-lg { font-size: var(--fs-500); }

.muted { color: #334155; opacity: 0.85; }

/* Eyebrow label (uppercase small label) */
.eyebrow { font-size: var(--fs-200); letter-spacing: 0.06em; text-transform: uppercase; font-weight: var(--fw-medium); opacity: 0.8; }

/* Links */
a:hover { text-decoration: none; }

/* Buttons (typography only; visuals remain in templates) */
button, .button { font-size: var(--fs-300); font-weight: var(--fw-semibold); line-height: 1.2; }

/* Header utility text often used for tenant/user labels */
.header-subtle { font-size: var(--fs-200); opacity: 0.95; }

/* ---- Layout shell and shared components ---- */
* { box-sizing: border-box; }
html, body { height: 100%; }

/* Grid shell applied to <body class="shell"> */
.shell {
  margin: 0;
  background: var(--theme-color-background);
  display: grid;
  grid-template-rows: 100px 1fr 18px;
  grid-template-columns: 220px 1fr;
  grid-template-areas:
    "header header"
    "sidebar content";
  transition: grid-template-columns 0.3s ease;
}

/* Adjust grid when sidebar is collapsed */
.shell:has(.shell-sidebar.collapsed) {
  grid-template-columns: 60px 1fr;
}

/* Header */
.shell-header {
  grid-area: header;
  background: var(--theme-header-background);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
}

.brand { display: flex;}
.brand-logo { height: 45px; width: auto; display: block; margin-bottom: 8px;}
.app-name { height: 25px; margin: 12px 15px 15px 18px;}
.top-right { display: flex; align-items: center; gap: 24px; }
.tenant { border-bottom: 1px solid rgba(255,255,255,.35); padding-bottom: 2px; }

/* User menu */
.user-menu { position: relative; }
.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: white;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.user-menu-button:hover { background: rgba(255,255,255,0.08); }
.user-menu-button:focus { outline: 2px solid rgba(255,255,255,0.4); outline-offset: 2px; }
.user-menu .caret { opacity: 0.9; transition: transform .15s ease; }
.user-menu[aria-expanded="true"] .caret, .user-menu.open .caret { transform: rotate(180deg); }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--theme-color-background);
  color: var(--theme-color-foreground);
  min-width: 200px;
  border: 1px solid var(--theme-color-neutral-n200);
  border-radius: 10px;
  box-shadow: var(--theme-shadow-elevation-2);
  padding: 6px 0;
  z-index: 1000;
}
.menu-item {
  width: 100%;
  background: transparent;
  border: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.menu-item:hover { background: var(--theme-color-neutral-n100); }

/* Sidebar */
.shell-sidebar {
  grid-area: sidebar;
  background: var(--theme-color-neutral-n100);
  border-right: 1px solid var(--theme-color-neutral-n200);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 4px 0 4px 0;
  transition: width 0.3s ease, padding 0.3s ease;
  overflow: hidden;
}

/* Sidebar toggle button */
.sidebar-toggle {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--theme-color-foreground);
  cursor: pointer;
  padding: 8px;
  margin: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: right;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}

.sidebar-toggle svg {
  transition: transform 0.3s ease;
}

.sidebar-toggle:hover {
  background: var(--theme-color-neutral-n200);
}

.collapsed .sidebar-toggle {
  justify-content: center;
}

/* Collapsed sidebar state */
.shell-sidebar.collapsed {
  width: 60px;
}

/* Rotate toggle icon when collapsed */
.shell-sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Keep nav visible but hide text elements */
.shell-sidebar.collapsed .sidebar-section-title {
  display: none;
}

/* Hide text nodes in links (keep icons) */
.shell-sidebar.collapsed .sidebar-link {
  font-size: 0;
  padding: 12px 8px;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}

/* Active state for collapsed sidebar - show indicator on right */
.shell-sidebar.collapsed .sidebar-link.active {
  border-right: 3px solid var(--theme-color-primary);
  padding-left: 16px;
}

/* Sidebar navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

/* Divider between public and internal sections */
.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--theme-color-neutral-n200);
  padding-top: 16px;
}

.sidebar-section-title {
  font-size: var(--fs-200);
  font-weight: var(--fw-semibold);
  color: var(--theme-color-foreground);
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 16px 4px 16px;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--theme-color-foreground);
  font-size: var(--fs-200);
  font-weight: var(--fw-medium);
  transition: background-color 0.15s ease;
  position: relative;
  text-align: left;
  word-wrap: break-word;
  line-height: var(--lh-tight);
}

.sidebar-link:hover {
  background: var(--theme-color-neutral-n200);
}

.sidebar-link.active {
  background: var(--theme-color-primary-p50);
  color: var(--theme-color-primary);
  font-weight: var(--fw-semibold);
  border-right: 3px solid var(--theme-color-primary);
  padding-left: 13px;
}

/* Render the masked glyph on a pseudo-element so the parent border isn't clipped */
.side-ico::before{
    font-size: x-large;
}

/* Main content */
.shell-content {
    grid-area: content;
    padding: 24px;
    background: var(--theme-color-background);
    position: relative;
    overflow: hidden;
}

/* Panel (card) */
.panel { max-width: 560px; background: white; border: 1px solid var(--theme-color-neutral-n200); border-radius: 10px; padding: 24px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }

/* Buttons (visuals) */
.button, button {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--theme-color-neutral-n200);
  background: var(--theme-color-neutral-n50);
  color: var(--theme-color-foreground);
  text-decoration: none;
  cursor: pointer;
}
.button:hover, button:hover { background: var(--theme-color-neutral-n100); }

/* Utility spacing */
.mt-4 { margin-top: 1rem; }

/* Dashboard fill behavior */
#dashboard-content { position: absolute; inset: 0; max-width: 100%; max-height: 100%; }

/* Sidebar mark */
.sidebar-mark { margin-top: auto; margin-left: auto; margin-right: auto; width: 57px; height: 53px; opacity: 0.9; }

/* ---- Chat drawer ---- */
.chat-button {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chat-button:hover { background: rgba(255,255,255,0.18); }
.chat-button .chat-button-label { display: none; }
@media (min-width: 900px) { .chat-button .chat-button-label { display: inline; } }

.chat-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--theme-color-primary);
  color: white;
  box-shadow: 0 3px 12px rgba(0,0,0,.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
@media (min-width: 900px) { .chat-fab { display: none; } }
.chat-fab:hover { filter: brightness(1.05); }

.chat-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  max-width: 95vw;
  height: 100%;
  background: var(--theme-color-background);
  border-left: 1px solid var(--theme-color-neutral-n200);
  box-shadow: -4px 0 16px rgba(0,0,0,.18);
  z-index: 1200;
  transition: right .28s ease;
  display: flex;
  flex-direction: column;
}
.chat-drawer.open { right: 0; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--theme-color-neutral-n200);
  background: var(--theme-color-neutral-n50);
}
.chat-title { display: inline-flex; gap: 8px; align-items: center; font-weight: var(--fw-semibold); }
.chat-actions { display: inline-flex; align-items: center; gap: 8px; }
.chat-popout { 
  text-decoration: none; 
  font-size: var(--fs-200); 
  color: white; 
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}
.chat-popout:hover { background: rgba(255,255,255,0.1); }
.chat-popout i { font-size: 1.2em; }
.chat-close { border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; }

.chat-frame {
  width: 100%;
  height: 100%;
  flex: 1;
  border: 0;
  background: white;
}
.chat-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--theme-color-neutral-n200);
  background: var(--theme-color-neutral-n50);
}

/* Simple resize handle (left edge) */
.chat-resize-handle-left {
  position: absolute;
  left: -6px;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
}
