/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-border: #e5e7eb;
  --color-danger: #ef4444;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 56px;
  --transition-speed: 200ms;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* === Flash Messages === */
.flash-messages {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  animation: flash-in 0.3s ease;
}

.flash--notice { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash--alert { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Impersonation Banner === */
.impersonation-banner {
  background: #fbbf24;
  color: #1a1a2e;
  text-align: center;
  padding: 6px 16px;
  font-size: 13px;
}

.impersonation-banner__stop {
  background: none;
  border: 1px solid #1a1a2e;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
}

/* === App Layout === */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-speed) ease;
  overflow: hidden;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar[data-collapsed="true"] {
  width: var(--sidebar-collapsed-width);
}

.sidebar[data-collapsed="true"] .sidebar__label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar[data-collapsed="true"] .sidebar__section-title {
  height: 1px;
  margin: 8px 12px;
  padding: 0;
  background: var(--color-border);
  overflow: hidden;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  gap: 8px;
}

.sidebar__logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  transition: opacity var(--transition-speed) ease;
}

.sidebar__logo--icon {
  display: none;
  height: 28px;
  width: 28px;
  cursor: pointer;
}

.sidebar[data-collapsed="true"] .sidebar__logo--full {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar[data-collapsed="true"] .sidebar__logo--icon {
  /* shown via media query only */
}

.sidebar__toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__toggle:hover { background: var(--color-bg); }

.sidebar__nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--color-text-muted);
  transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
  white-space: nowrap;
}

.sidebar__link:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.sidebar__link--active {
  background: #eef2ff;
  color: var(--color-primary);
  font-weight: 500;
}

.sidebar__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar__label {
  transition: opacity var(--transition-speed) ease;
}

.sidebar__section-title {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.sidebar__footer {
  padding: 12px 8px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar__version {
  padding: 2px 8px;
  font-size: 11px;
  color: var(--color-text-muted);
  opacity: 0.6;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.sidebar__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.sidebar__avatar--placeholder {
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.sidebar__user-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__link--sign-out { color: var(--color-danger); }
.sidebar__link--sign-out:hover { background: #fef2f2; }

/* === Main Content === */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  transition: margin-left var(--transition-speed) ease;
  min-height: 100vh;
}

.sidebar[data-collapsed="true"] ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* === Under Construction Page === */
.construction {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: url("/nasa-deep-field.jpg") center center / cover no-repeat fixed;
  background-color: #0a0a1a;
}

.construction__overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
}

.construction__content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  padding: 48px;
}

.construction__title {
  font-size: 56px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
  margin-bottom: 16px;
}

.construction__divider {
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  margin: 0 auto 24px;
}

.construction__text {
  font-size: 22px;
  font-weight: 300;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.construction__subtext {
  font-size: 15px;
  color: rgba(255,255,255,0.5);
  font-weight: 300;
}

.construction__credit {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 300;
  color: rgba(255,255,255,0.3);
  text-decoration: none;
  z-index: 1;
  letter-spacing: 0.05em;
}

@media (max-width: 480px) {
  .construction__title { font-size: 36px; }
  .construction__text { font-size: 16px; }
  .construction__content { padding: 24px; }
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 150ms ease;
  text-decoration: none;
}

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

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

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover { background: var(--color-bg); }

.btn--google {
  background: #4285f4;
  color: white;
  width: 100%;
}

.btn--google:hover { background: #3367d6; }

.btn--small {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 6px;
}

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

.btn--danger:hover { background: #dc2626; }

/* === Dashboard === */
.dashboard__title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.dashboard__welcome {
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

.dashboard__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.dashboard__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.dashboard__card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 12px rgba(79, 70, 229, 0.1);
}

.dashboard__card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dashboard__card-desc {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* === Brief Form === */
.brief-page__title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.brief-page__subtitle {
  color: var(--color-text-muted);
  font-size: 15px;
  margin-bottom: 24px;
}

.brief-form {
  max-width: 720px;
}

.brief-form__errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 14px;
}

.brief-form__errors ul { margin-top: 6px; padding-left: 18px; }
.brief-form__errors li { margin-bottom: 2px; }

.brief-form__section {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  background: var(--color-surface);
}

.brief-form__legend {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
  padding: 0 8px;
}

.brief-form .field {
  margin-bottom: 16px;
}

.brief-form .field:last-child {
  margin-bottom: 0;
}

.brief-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--color-text);
}

.brief-form input[type="text"],
.brief-form input[type="email"],
.brief-form input[type="date"],
.brief-form textarea,
.brief-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 150ms ease;
  background: white;
}

.brief-form input:focus,
.brief-form textarea:focus,
.brief-form select:focus {
  border-color: var(--color-primary);
}

.brief-form textarea {
  resize: vertical;
  min-height: 60px;
}

.brief-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Deliverable rows */
.brief-form__deliverable-row {
  margin-bottom: 8px;
}
.brief-form__deliverable-fields {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.brief-form__deliverable-field--desc { flex: 2; }
.brief-form__deliverable-field--resp { flex: 1; }
.brief-form__deliverable-field--date { flex: 0 0 160px; }
.brief-form__deliverable-fields .field { margin-bottom: 0; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 6px 8px; border-radius: 4px; color: var(--color-text-muted); }
.btn-icon:hover { background: var(--color-bg); }
.btn-icon--danger:hover { color: var(--color-danger); }
.btn--sm { font-size: 13px; padding: 6px 12px; }

.brief-form__checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.brief-form__checkbox,
.brief-form__radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.brief-form__checkbox input,
.brief-form__radio input {
  width: auto;
  margin: 0;
  accent-color: var(--color-primary);
}

.brief-form__radios {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.brief-form__urgency {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

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

.brief-form__urgency-option {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  cursor: pointer;
}

.brief-form__urgency-option input {
  width: auto;
  margin: 0;
  accent-color: var(--color-primary);
}

.brief-form__file {
  margin-top: 4px;
}

.brief-form__hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.brief-form__attached {
  font-size: 13px;
  color: var(--color-primary);
  margin-top: 4px;
}

.brief-form__actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

/* === Brief Show === */
.brief-show__status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

.brief-show__status-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brief-show__status-form select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.brief-show__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.brief-show__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px;
}

.brief-show__card--full { grid-column: 1 / -1; }
.brief-show__card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.brief-show__dl {
  display: grid;
  gap: 12px;
}

.brief-show__dl dt {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.brief-show__dl dd {
  font-size: 14px;
  line-height: 1.5;
}

.brief-show__dl dd p { margin: 0; }

.brief-show__download {
  color: var(--color-primary) !important;
  font-weight: 500;
}

.brief-show__download:hover { text-decoration: underline; }

/* === Print / PDF === */
@media print {
  .sidebar, .flash-messages, .impersonation-banner,
  .admin-invitations__header .btn,
  .brief-show__status-bar form,
  .sharing-panel, .brief-show__status-form { display: none !important; }

  .app-layout { display: block !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .brief-page { padding: 0 !important; }

  .brief-show__grid { grid-template-columns: 1fr 1fr !important; }
  .brief-show__card {
    break-inside: avoid;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }

  a[href]::after { content: none !important; }
  body { background: white !important; color: black !important; }
}

/* Brief status badges */
.admin-badge--submitted { background: #dbeafe; color: #1d4ed8; }
.admin-badge--in_review { background: #fef3c7; color: #92400e; }
.admin-badge--approved { background: #ecfdf5; color: #065f46; }
.admin-badge--rejected { background: #fef2f2; color: #991b1b; }
.admin-badge--draft { background: var(--color-bg); color: var(--color-text-muted); }

/* Urgency badges */
.admin-badge--urgency-1, .admin-badge--urgency-2 { background: #ecfdf5; color: #065f46; }
.admin-badge--urgency-3 { background: #fef3c7; color: #92400e; }
.admin-badge--urgency-4, .admin-badge--urgency-5 { background: #fef2f2; color: #991b1b; }

/* === AI Features === */
.btn--ai {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  display: inline-flex;
  align-items: center;
}

.btn--ai:hover { background: linear-gradient(135deg, #6d28d9, #4338ca); }

.ai-generated-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  color: #4f46e5;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}

.ai-input {
  max-width: 720px;
}

.ai-input__nav {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.ai-input__tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: all 150ms ease;
  margin-bottom: -1px;
}

.ai-input__tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.ai-input__tab:hover { color: var(--color-text); }

.ai-input__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px;
}

.ai-input__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.ai-input__textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 150ms ease;
}

.ai-input__textarea:focus { border-color: var(--color-primary); }

.ai-input__actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* AI Full-screen overlay */
.ai-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}

.ai-overlay--open { display: flex; }

.ai-overlay__card {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 40px 48px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modal-in 0.2s ease;
}

.ai-overlay__spinner-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: #7c3aed;
  border-right-color: #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.ai-overlay__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ai-overlay__current {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 20px;
  min-height: 22px;
  transition: opacity 0.15s ease;
}

.ai-overlay__stages {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.ai-overlay__stage {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--color-text-muted);
  transition: color 0.2s ease;
}

.ai-overlay__stage--active {
  color: var(--color-primary);
  font-weight: 500;
}

.ai-overlay__stage--done {
  color: #059669;
}

.ai-overlay__stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.ai-overlay__stage--active .ai-overlay__stage-dot {
  background: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  animation: pulse-dot 1.5s ease infinite;
}

.ai-overlay__stage--done .ai-overlay__stage-dot {
  background: #059669;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.1); }
}

.ai-overlay__hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 0;
}

/* AI Assist button on fields */
.field__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.field__header label { margin-bottom: 0; }

.btn-ai-assist {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  border: none;
  padding: 2px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.btn-ai-assist:hover { opacity: 0.85; }
.btn-ai-assist:disabled { opacity: 0.5; cursor: wait; }

.brief-page__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.brief-page__header .brief-page__title { margin-bottom: 4px; }
.brief-page__header .brief-page__subtitle { margin-bottom: 0; }

/* === Sharing Panel === */
.sharing-panel__form {
  margin-bottom: 16px;
}

.sharing-panel__row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sharing-panel__input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.sharing-panel__input:focus {
  border-color: var(--color-primary);
}

.sharing-panel__select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.sharing-panel__table {
  margin-top: 12px;
}

.sharing-panel__inline-form {
  display: inline;
}

/* === Tool Page === */
.tool-page__title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.tool-page__placeholder {
  color: var(--color-text-muted);
}

/* === Devise Forms === */
.devise-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.devise-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
}

.devise-form h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.devise-form .field {
  margin-bottom: 16px;
}

.devise-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--color-text-muted);
}

.devise-form input[type="email"],
.devise-form input[type="password"],
.devise-form input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 150ms ease;
}

.devise-form input:focus {
  border-color: var(--color-primary);
}

.devise-form .actions {
  margin-top: 20px;
}

.devise-form .actions input[type="submit"] {
  width: 100%;
  padding: 10px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.devise-form .actions input[type="submit"]:hover {
  background: var(--color-primary-hover);
}

.devise-links {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  text-align: center;
}

.devise-links a {
  color: var(--color-primary);
}

.devise-links a:hover {
  text-decoration: underline;
}

/* === Admin === */
.admin-invitations__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-invitations__title {
  font-size: 24px;
  font-weight: 700;
}

.admin-invitations__empty {
  color: var(--color-text-muted);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 10px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.admin-badge--accepted, .admin-badge--online { background: #ecfdf5; color: #065f46; }
.admin-badge--pending { background: #fef3c7; color: #92400e; }
.admin-badge--admin { background: #eef2ff; color: var(--color-primary); }
.admin-badge--user { background: var(--color-bg); color: var(--color-text-muted); }
.admin-badge--external { background: #fef2f2; color: #991b1b; }
.admin-badge--offline { background: var(--color-bg); color: var(--color-text-muted); }
.admin-badge--deactivated { background: #fef2f2; color: #991b1b; }

.admin-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  margin-top: 20px;
}

.admin-form .field {
  margin-bottom: 16px;
}

.admin-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--color-text-muted);
}

.admin-form input[type="email"],
.admin-form input[type="text"],
.admin-form__select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 150ms ease;
  background: white;
}

.admin-form input:focus,
.admin-form__select:focus {
  border-color: var(--color-primary);
}

.admin-form .actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
}

.admin-table__user-link { display: block; }
.admin-table__user-link:hover strong { color: var(--color-primary); }

.admin-table__nowrap { white-space: nowrap; }

.admin-table__path {
  font-size: 13px;
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.user-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.user-stats__item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 20px;
  min-width: 140px;
}

.user-stats__label {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 4px;
}

.user-stats__value {
  font-size: 18px;
  font-weight: 700;
}

/* === Modal === */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal--open { display: flex; }

.modal__content {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 28px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  animation: modal-in 0.15s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal__body {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal__body strong { color: var(--color-text); }

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

/* === Sortable Table === */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sortable-th:hover {
  color: var(--color-primary);
}

.sortable-th::after {
  content: " \2195";
  opacity: 0.3;
  font-size: 10px;
}

.sortable-th.sorted-asc::after {
  content: " \2191";
  opacity: 1;
}

.sortable-th.sorted-desc::after {
  content: " \2193";
  opacity: 1;
}

/* === Briefs Search === */
.briefs-search__input {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  width: 260px;
  outline: none;
  transition: border-color 150ms ease;
}

.briefs-search__input:focus {
  border-color: var(--color-primary);
}

/* === Document Preview === */
.doc-preview {
  margin-top: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.doc-preview object {
  display: block;
}

.doc-preview__image {
  max-width: 100%;
  max-height: 500px;
  display: block;
}

/* === Public Shared Brief === */
.shared-brief {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

.shared-brief__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.shared-brief__logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.shared-brief__badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* === Responsive === */

/* Tables: always scroll gracefully */
.admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table thead,
.admin-table tbody,
.admin-table tr { display: table; width: 100%; table-layout: auto; }
.admin-table thead { display: table-header-group; }
.admin-table tbody { display: table-row-group; }

@media (max-width: 768px) {
  /* Sidebar: collapsed by default, expands as overlay on tap */
  .sidebar {
    width: var(--sidebar-collapsed-width);
    z-index: 200;
  }

  .sidebar__header { padding: 10px; gap: 0; justify-content: center; }

  .sidebar[data-collapsed="false"] {
    width: var(--sidebar-width);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .sidebar[data-collapsed="false"] .sidebar__header { padding: 12px 16px; justify-content: space-between; }

  .sidebar .sidebar__logo--full { opacity: 0; width: 0; overflow: hidden; }
  .sidebar .sidebar__logo--icon { display: block; }

  .sidebar[data-collapsed="false"] .sidebar__logo--full { opacity: 1; width: auto; }
  .sidebar[data-collapsed="false"] .sidebar__logo--icon { display: none; }

  .sidebar .sidebar__label { opacity: 0; width: 0; }
  .sidebar[data-collapsed="false"] .sidebar__label { opacity: 1; width: auto; }

  .sidebar .sidebar__toggle { display: none; }
  .sidebar[data-collapsed="false"] .sidebar__toggle { display: flex; }

  .main-content {
    margin-left: var(--sidebar-collapsed-width);
    padding: 12px;
  }

  /* Overlay backdrop when sidebar is open */
  .sidebar[data-collapsed="false"]::after {
    content: "";
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
  }

  /* Tighter spacing on mobile */
  h1 { font-size: 20px; }
  h3 { font-size: 16px; }

  .admin-invitations__header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 16px;
  }

  .admin-invitations__header > div:last-child { flex-wrap: wrap; }

  .brief-show__grid { grid-template-columns: 1fr; }
  .brief-show__card { padding: 12px; }

  .branding-dashboard__cards { grid-template-columns: 1fr; }
  .branding-dashboard__card { padding: 16px; }
  .branding-dashboard__card-value { font-size: 22px; }

  .cqs-results__header { flex-direction: column; align-items: center; gap: 24px; margin-top: 20px; }
  .cqs-fundamentals__grid { grid-template-columns: 1fr; }

  .dashboard__cards { grid-template-columns: 1fr; }

  .brief-show__dl dt { font-size: 12px; }
  .brief-show__dl dd { font-size: 13px; }

  .admin-table th, .admin-table td { padding: 8px 10px; font-size: 13px; }

  .btn { padding: 8px 16px; font-size: 13px; }

  .cqs-gauge__circle { width: 130px; height: 130px; }
  .cqs-gauge__circle::before { width: 100px; height: 100px; }
  .cqs-gauge__value { font-size: 26px; }

  .modal__content { margin: 16px; padding: 20px; }
}

/* === Brief Card Headers with Comment Toggle === */
.brief-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.brief-card__header h3 { margin: 0; }

.brief-card__comment-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.brief-card__comment-toggle:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}

.brief-card__comment-count:empty { display: none; }

/* === Comment Thread === */
.comment-thread {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.comment-thread__item {
  padding: 10px 12px;
  background: var(--color-bg);
  border-radius: 6px;
  margin-bottom: 8px;
}

.comment-thread__meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.comment-thread__meta strong {
  color: var(--color-text);
}

.comment-thread__body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.comment-thread__form { margin-top: 8px; }

.comment-thread__input,
.comment-thread__name-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

.comment-thread__name-input { margin-bottom: 8px; }

.comment-thread__input:focus,
.comment-thread__name-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* === Share Modal Sections === */
.share-section__label {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.share-section__hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0 0 10px 0;
}

.share-email-form__input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
}

.share-email-form__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* === Creative Suggestions === */
.creative-suggestions__loading,
.creative-suggestions__error {
  padding: 20px;
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
}

.creative-suggestions__error { color: #991b1b; }

.creative-suggestion {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 12px;
}

.creative-suggestion__number {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.creative-suggestion__concept {
  font-size: 18px;
  margin: 0 0 16px 0;
  padding: 4px;
  border-radius: 4px;
  outline: none;
}

.creative-suggestion__concept:focus {
  background: #f0f0ff;
}

.creative-suggestion__field {
  margin-bottom: 12px;
}

.creative-suggestion__field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 4px;
}

.creative-suggestion__field p {
  margin: 0;
  padding: 6px;
  border-radius: 4px;
  outline: none;
  line-height: 1.5;
  font-size: 14px;
}

.creative-suggestion__field p:focus {
  background: #f0f0ff;
}

/* === Branding / CreativeIQ Hub === */
.branding-page__title { margin: 0; }
.branding-page__subtitle { color: var(--color-text-muted); margin-top: 4px; font-size: 14px; }

.branding-dashboard__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.branding-dashboard__card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.branding-dashboard__card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.1);
}

.branding-dashboard__card-icon { color: var(--color-primary); margin-bottom: 12px; }
.branding-dashboard__card-value { font-size: 28px; font-weight: 700; }
.branding-dashboard__card-label { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

/* Audit Tabs */
.audit-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--color-border); }

.audit-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.audit-tab:hover { color: var(--color-text); }
.audit-tab--active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.audit-panel { padding-top: 24px; }

/* CQS Gauge */
.cqs-results__header {
  display: flex;
  gap: 40px;
  align-items: center;
  margin-top: 32px;
  flex-wrap: wrap;
}

.cqs-gauge { flex-shrink: 0; }

.cqs-gauge__circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(
    #4f46e5 calc(var(--score) * 3.6deg),
    #e5e7eb calc(var(--score) * 3.6deg)
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cqs-gauge__circle::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: white;
}

.cqs-gauge__value {
  position: relative;
  z-index: 1;
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
}

.cqs-gauge__label {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ABCD Dimensions */
.cqs-dimensions { flex: 1; min-width: 250px; }
.cqs-dimensions h3 { margin: 0 0 16px 0; }

.cqs-dimension { margin-bottom: 12px; }

.cqs-dimension__header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.cqs-dimension__label { font-weight: 500; }
.cqs-dimension__score { font-weight: 600; }

.cqs-dimension__bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.cqs-dimension__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.cqs-dimension__fill--high { background: #059669; }
.cqs-dimension__fill--medium { background: #d97706; }
.cqs-dimension__fill--low { background: #dc2626; }

/* Fundamentals Grid */
.cqs-fundamentals__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.cqs-fundamental {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.cqs-fundamental__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.cqs-fundamental__icon--met { background: #ecfdf5; color: #059669; }
.cqs-fundamental__icon--not-met { background: #fef2f2; color: #dc2626; }
.cqs-fundamental__icon--na { background: #f3f4f6; color: #9ca3af; }

.cqs-fundamental__label { font-weight: 500; font-size: 14px; }
.cqs-fundamental__dimension { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cqs-fundamental__note { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; line-height: 1.4; }

/* CQS Score Inline */
.cqs-score-inline { font-weight: 600; }
.cqs-score-inline--high { color: #059669; }
.cqs-score-inline--medium { color: #d97706; }
.cqs-score-inline--low { color: #dc2626; }

/* Hide comments and suggestions in print */
@media print {
  .comment-thread, .brief-card__comment-toggle, .share-section, .creative-suggestions { display: none !important; }
}
