/* ============================================================
   CODEBLOOM — SHARED STYLESHEET
   Cross-app chrome: design tokens, base, buttons, header,
   ecosystem rail, and modals. Workspace styles live in each
   app's own styles.css.

   Source of truth for the suite. Keep app-specific rules OUT
   of this file — chrome/brand/nav belongs here, workspace does
   not. Variable definitions are at the top by design.
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */

:root {
  /* Colors */
  --primary: #4e4eff;
  --secondary: #dfef44;
  --accent: #ff457a;
  --black: #0a0a0f;
  --white: #fafafe;
  --bg: #eaf5ff;
  --border: #4e4eff;

  /* Font sizes — max 4, reuse everywhere */
  --fs-xl: 24px;
  --fs-lg: 16px;
  --fs-md: 13px;
  --fs-sm: 11px;

  /* Spacing */
  --large: 20px;
  --medium: 10px;
  --small: 5px;

  /* Radius */
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 6px;

  /* Typeface */
  --font: "Kode Mono", monospace;
}

/* ============================================================
   2. RESET
   ============================================================ */

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

/* ============================================================
   3. BASE
   ============================================================ */

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  background: var(--white);
  color: var(--black);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: var(--large) 0;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font);
  cursor: pointer;
}

/* Headings — one definition each, reused everywhere (modal titles, …) */
h3 {
  font-size: var(--fs-lg);
  font-weight: 700;
}

h4 {
  font-size: var(--fs-md);
  font-weight: 700;
}

/* ============================================================
   4. BUTTONS
   ============================================================ */

.btn {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--small) var(--medium);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

/* Primary = yellow, the featured CTA (use one per surface) */
.btn--primary {
  background: var(--secondary);
  border-color: var(--secondary);
  color: var(--primary);
}

.btn--primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Secondary = filled blue (the former primary) */
.btn--secondary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.btn--secondary:hover {
  opacity: 0.85;
}

/* Outline = blue outline, the default */
.btn--outline {
  background: transparent;
  color: var(--primary);
}

.btn--outline:hover {
  background: var(--primary);
  color: var(--white);
}

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.btn--accent:hover {
  opacity: 0.85;
}

.btn--small {
  padding: 2px var(--small);
  font-size: var(--fs-sm);
}

/* ============================================================
   5. HEADER
   ============================================================ */

.header {
  display: flex;
  align-items: baseline;
  gap: var(--medium);
  padding: 0 var(--large) var(--large) var(--large);
  width: 100%;
  flex-shrink: 0;
}

.header__left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.header__brand {
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.header__sep {
  color: var(--black);
  font-size: 18px;
  font-weight: 700;
}

.header__app {
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--primary);
}

.header__center {
  display: flex;
  align-items: baseline;
  gap: var(--small);
  flex: 1;
  min-width: 0;
}

.header__btn {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--small) var(--medium);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.header__btn:hover {
  background: var(--primary);
  color: var(--white);
}

.header__right {
  display: flex;
  align-items: center;
  gap: var(--medium);
  flex-shrink: 0;
}

.header__greeting {
  font-size: 14px;
  font-weight: 500;
}

.header__signout {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--small) var(--medium);
  border: 2px solid var(--black);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--black);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.header__signout:hover {
  opacity: 1;
}

/* Class code widget */

.header__class {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header__class-input {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--small) var(--medium);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  width: 90px;
  outline: none;
  transition: border-color 0.15s;
}

.header__class-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 78, 255, 0.15);
}

.header__class-input::placeholder {
  color: var(--black);
  opacity: 0.35;
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
}

.header__class-badge {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: var(--white);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--small) var(--medium);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
}

.header__class-leave {
  display: none;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0; /* hide the button's own text; the glyph is drawn below */
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.header__class-leave::before {
  content: "\00D7"; /* × — owned here so the glyph is a single-place change */
  font-size: 18px;
}

.header__class-leave:hover {
  opacity: 1;
}

.header__class.active .header__class-input {
  display: none;
}

.header__class.active .header__class-badge {
  display: flex;
}

.header__class.active .header__class-leave {
  display: inline-block;
}

/* ============================================================
   6. LAYOUT COLUMNS
   Shared positional shells for the workspace grid. Each app
   sets its own grid-template-columns and fills these with its
   own contents (and may add a semantic class alongside).
   ============================================================ */

/* Ecosystem rail — blue far-left column for cross-app navigation. */

.sidebar {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: var(--large) var(--small);
}

.sidebar__top,
.sidebar__bottom {
  display: flex;
  flex-direction: column;
  gap: var(--large);
  align-items: center;
}

.sidebar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sidebar__btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}

.sidebar__btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--white);
}

.sidebar__btn svg {
  width: 22px;
  height: 22px;
}

.sidebar__label {
  font-family: var(--font);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--white);
  text-align: center;
  white-space: nowrap;
}

/* Left panel — the tools column between the rail and the canvas.
   Positional shell only; apps style their own contents and may add a
   semantic class (e.g. .palette in SiteStack, .tools-panel in Studio). */

.left-panel {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Right panel — the edit-tools column on the far right. Positional
   shell only; apps fill it with their own .panel cards and may add a
   semantic class (e.g. .settings in SiteStack, .inspector in Studio). */

.right-panel {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

/* ============================================================
   7. PANEL
   Rounded card with a colored header bar. Used for any
   collapsible side-panel section across apps (settings,
   inspector, blocks). Default header is primary; --accent
   gives the red variant.
   ============================================================ */

.panel {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.panel--hidden {
  display: none;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--small) var(--medium);
  background: var(--primary);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--white);
  transition: filter 0.15s;
}

.panel__header:hover {
  filter: brightness(0.92);
}

.panel__chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.2s;
}

.panel--collapsed .panel__chevron {
  transform: rotate(-90deg);
}

.panel--collapsed .panel__body {
  display: none;
}

.panel__body {
  padding: var(--medium);
}

/* Accent variant — red header (e.g. an Actions panel) */

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

.panel--accent .panel__header {
  background: var(--accent);
}

/* ============================================================
   8. MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(10, 10, 15, 0.15);
}

.modal--wide {
  max-width: 720px;
}

/* Windowed modal — blue draggable header bar + padded content.
   Used for list modals like the shared Sites/share modal. */
.modal--window {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--medium) var(--large);
  background: var(--primary);
  color: var(--white);
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.modal__bar-title {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.modal__bar-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
  padding: 0 var(--small);
  transition: opacity 0.15s;
}

.modal__bar-close:hover {
  opacity: 0.75;
}

.modal__content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--large);
}

.modal__title {
  margin-bottom: var(--medium);
}

.modal__text {
  font-size: var(--fs-md);
  margin-bottom: var(--medium);
  line-height: 1.5;
  opacity: 0.6;
}

.modal__field {
  margin-bottom: var(--medium);
}

.modal__label {
  display: block;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: var(--small);
}

.modal__input,
.modal__select {
  font-family: var(--font);
  font-size: var(--fs-md);
  width: 100%;
  padding: var(--small) var(--medium);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--black);
  outline: none;
  transition: border-color 0.15s;
}

.modal__input:focus,
.modal__select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 78, 255, 0.15);
}

.modal__select {
  cursor: pointer;
}

.modal__error {
  font-size: var(--fs-sm);
  color: var(--accent);
  margin-bottom: var(--small);
}

.modal__buttons {
  display: flex;
  gap: var(--medium);
  justify-content: center;
  margin-top: var(--medium);
}

.modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.modal__empty-text {
  color: #888;
  text-align: center;
  padding: var(--large);
}

/* ============================================================
   9. SAVE / SHARE UI
   List rows and tabs used by the share modal that ships with
   saves.js. Lives here so any app linking the module gets it.
   ============================================================ */

.load-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--medium);
  padding: var(--medium) var(--large);
  background: var(--bg);
  border-radius: var(--radius-md);
  margin-bottom: var(--small);
}

.load-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.load-card__actions {
  display: flex;
  gap: var(--small);
  flex-shrink: 0;
}

.load-card__name {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--black);
}

.load-card__date {
  font-size: var(--fs-sm);
  color: #999;
}

/* Segmented toggle (My X | Class) */
.share-tabs {
  display: inline-flex;
  align-self: flex-start;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--medium);
}

.share-tabs__btn {
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  padding: var(--small) var(--medium);
  border: none;
  border-right: 2px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
}

.share-tabs__btn:last-child {
  border-right: none;
}

.share-tabs__btn:hover:not(.share-tabs__btn--active) {
  background: var(--bg);
}

.share-tabs__btn--active {
  background: var(--primary);
  color: var(--white);
}
