/* ---------------------------------------------------------------
   CSS reset + brand variables (Indigo dark theme)
--------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-width: 260px;
  --header-height: 52px;
  --content-max-width: 760px;

  /* Brand colors (android-reference.md) */
  --color-bg:          #0D0F1A;
  --color-surface:     #1A1D2E;
  --color-surface-2:   #222538;
  --color-border:      #2A2D3E;
  --color-primary:     #5B21FA;
  --color-primary-light: #7C3AED;
  --color-accent:      #0ECFB8;
  --color-text:        #F0F2FF;
  --color-text-muted:  #8B8FA8;
  --color-danger:      #FF4D6D;

  /* Gradient */
  --gradient: linear-gradient(135deg, #5B21FA, #0ECFB8);

  /* User bubble */
  --color-user-bubble: #222538;
  --color-user-bubble-text: #F0F2FF;

  --radius:    12px;
  --radius-sm: 6px;
  --radius-lg: 20px;
  --shadow:    0 2px 8px rgba(0,0,0,0.35);
}

html, body {
  height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------
   Two-column layout
--------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--color-bg);
}

/* ---------------------------------------------------------------
   Main header
--------------------------------------------------------------- */
.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-title {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  flex-shrink: 0;
  line-height: 1;
}

.hamburger:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* ---------------------------------------------------------------
   Input bar — centered column, pinned to bottom
--------------------------------------------------------------- */
.input-area {
  flex-shrink: 0;
  padding: 12px 16px 20px;
  background: var(--color-bg);
}

.input-area-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Row: text input + generate button side by side */
.input-row-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.input-row {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 8px 10px 8px 16px;
  transition: border-color 0.15s;
  min-width: 0;
}

.input-row:focus-within {
  border-color: var(--color-primary);
}

.message-input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 6px 0;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--color-text);
  max-height: 160px;
  overflow-y: auto;
  min-width: 0;
}

.message-input::placeholder {
  color: var(--color-text-muted);
}

.message-input:focus {
  outline: none;
}

/* Send — small icon button inside the input row */
.send-icon-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.send-icon-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

.send-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Generate — standalone tall pill button */
.generate-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  height: 52px;           /* matches typical input-row height */
  letter-spacing: -0.01em;
  transition: opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 0 rgba(91,33,250,0);
}

.generate-btn:hover {
  opacity: 0.9;
  box-shadow: 0 4px 16px rgba(91,33,250,0.35);
}

.generate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.generate-wrap {
  flex-shrink: 0;
}

/* Mobile toggle hidden by default — parent selector beats .gen-model-toggle { display: flex } */
.generate-wrap .gen-model-toggle {
  display: none;
}

/* Flash / Reason segmented toggle */
.gen-model-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.gen-model-opt {
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  transition: background 0.12s, color 0.12s;
}

.gen-model-opt:hover {
  color: var(--color-text);
}

.gen-model-opt.active {
  background: var(--color-primary);
  color: #fff;
}

.input-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.input-hint-text {
  flex: 1;
  text-align: center;
}

/* ---------------------------------------------------------------
   Modal dialog
--------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 300px;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
}
.modal-input:focus { outline: none; border-color: var(--color-primary); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
}
.modal-btn-cancel {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.modal-btn-cancel:hover { color: var(--color-text); background: var(--color-border); }
.modal-btn-ok { background: var(--color-primary); color: #fff; }
.modal-btn-ok:hover { opacity: 0.85; }
.modal-btn-danger { background: var(--color-danger); color: #fff; }
.modal-btn-danger:hover { opacity: 0.85; }

/* ---------------------------------------------------------------
   Shared chat view
--------------------------------------------------------------- */
.shared-view { width: 100%; }
body > .shared-view { height: 100vh; }

.shared-logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  margin-right: 4px;
}

.shared-owner-label {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.shared-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.shared-action-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.shared-action-btn:hover { background: var(--color-border); border-color: var(--color-primary); }
.shared-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.shared-action-btn-accent {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.shared-action-btn-accent:hover { opacity: 0.85; background: var(--color-primary); }

/* ---------------------------------------------------------------
   Mobile (< 640px)
--------------------------------------------------------------- */
@media (max-width: 639px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hamburger {
    display: block;
  }

  .shared-owner-label { display: none; }

  /* Mobile input: textarea full width, generate + toggle below */
  .input-row-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .generate-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .generate-btn {
    flex: 1;
    justify-content: center;
    height: 42px;
  }

  .generate-wrap .gen-model-toggle { display: flex; }
  .input-hint .gen-model-toggle { display: none; }

  .input-hint { display: none; }
}
