/* Milton Beta — Design System */
@import url('https://fonts.googleapis.com/css2?family=Dela+Gothic+One&family=Inter:wght@400;500;600;700&display=swap');

/* ── Tokens ── */
:root {
  --blue: #003DFF;
  --yellow: #D3FF33;
  --orange: #FF5C22;
  --purple: #9D00FF;
  --black: #000000;
  --grey: #979797;
  --bg: #F5F5F5;
  --white: #FFFFFF;
  --border: 1px solid var(--black);
  --pad: 16px;
  --gap: 24px;
  --font-headline: 'Dela Gothic One', system-ui, sans-serif;
  --font-body: Georgia, serif;
  --font-ui: 'Inter', system-ui, sans-serif;
}

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--black);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Typography ── */
h1, h2, h3 { font-family: var(--font-headline); font-weight: 400; line-height: 1.2; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

/* ── Layout ── */
.container { max-width: 720px; margin: 0 auto; padding: 0 var(--pad); }
.screen { display: none; }
.screen.active { display: block; }

/* ── Login ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}

.login-box {
  background: var(--white);
  border: var(--border);
  padding: 48px 32px;
  width: 100%;
  max-width: 400px;
}

.login-box h1 { text-align: center; margin-bottom: 8px; }
.login-box .subtitle {
  text-align: center;
  font-family: var(--font-ui);
  color: var(--grey);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 32px;
}

/* ── Forms ── */
label {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--black);
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 12px var(--pad);
  border: var(--border);
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  border-width: 2px;
  padding: 11px calc(var(--pad) - 1px);
}

textarea { min-height: 200px; resize: vertical; font-family: var(--font-ui); }
.form-group { margin-bottom: var(--pad); }
.form-row { display: flex; gap: var(--pad); }
.form-row > * { flex: 1; }

.error-msg {
  background: #FEE;
  border: 2px solid #C00;
  padding: 10px var(--pad);
  font-family: var(--font-ui);
  font-size: 14px;
  color: #900;
  margin-bottom: var(--pad);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-outline { background: transparent; border: 2px solid var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; border: none; color: var(--blue); padding: 8px 0; font-weight: 600; }
.btn-danger { background: #C00; color: var(--white); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ── Header ── */
.header {
  background: var(--white);
  border-bottom: var(--border);
  padding: var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h3 { font-size: 16px; }
.header-right { display: flex; align-items: center; gap: var(--pad); }
.header-right .tester-name { font-family: var(--font-ui); font-size: 13px; color: var(--grey); }

/* ── Section Title Bar ── */
.section-title-bar {
  border-bottom: var(--border);
  background: var(--white);
  position: sticky;
  top: 57px;
  z-index: 9;
  padding: 12px var(--pad);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
}

/* ── Info Box (collapsible) ── */
.info-box {
  background: var(--yellow);
  border: var(--border);
  margin: var(--gap) auto 0;
  max-width: 720px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
}

.info-box summary {
  padding: 12px var(--pad);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-box summary::-webkit-details-marker { display: none; }

.info-box summary::after {
  content: '▸';
  font-size: 14px;
  margin-left: auto;
  transition: transform 0.15s;
}

.info-box[open] summary::after {
  transform: rotate(90deg);
}

.info-box-content {
  padding: 0 var(--pad) var(--pad);
}

.info-box strong {
  font-weight: 700;
}

.info-box ul {
  margin: 8px 0 8px 20px;
  list-style: disc;
}

.info-box li {
  margin-bottom: 2px;
}

.stock-list { list-style: none !important; margin-left: 0 !important; }
.stock-list li { display: flex; align-items: center; gap: 8px; }
.stock-icon { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; }

.info-box p {
  margin-bottom: 8px;
}

.info-box p:last-child {
  margin-bottom: 0;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border: var(--border);
  padding: var(--pad);
  overflow: hidden;
}

.article-card { margin-bottom: var(--pad); }

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 2px solid var(--black);
}

.tag-personalized { background: var(--blue); color: var(--white); }
.tag-portfolio_digest { background: var(--yellow); color: var(--black); }

.card-meta .date {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--grey);
}

.article-title { margin-bottom: 12px; }

.article-content {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.75;
  color: #222;
  overflow-wrap: break-word;
  word-break: break-word;
}

.article-content h2 { font-size: 20px; margin: 24px 0 12px; }
.article-content h3 { font-size: 17px; margin: 20px 0 8px; }
.article-content p { margin-bottom: 16px; }
.article-content ul, .article-content ol { margin: 0 0 16px 24px; }
.article-content li { margin-bottom: 6px; }
.article-content strong { font-weight: 700; }

/* ── Survey Questions ── */
.survey-intro {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--grey);
  line-height: 1.5;
  margin-bottom: 20px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.survey-question { margin-bottom: 20px; }

.question-text {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.4;
}

.scale-row { display: flex; gap: 8px; margin-bottom: 6px; }

.scale-btn {
  width: 44px;
  height: 44px;
  border: var(--border);
  background: var(--white);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.scale-btn:hover { background: var(--bg); }
.scale-btn.selected { background: var(--blue); color: var(--white); border-color: var(--blue); }
.scale-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.scale-btn:disabled.selected { opacity: 1; }

.scale-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--grey);
  max-width: 236px;
}

.scale-detail {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--grey);
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: break-word;
}

.choice-group { display: flex; flex-direction: column; gap: 6px; }

.choice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: var(--border);
  background: var(--white);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 14px;
  transition: all 0.15s;
}

.choice-option:hover { background: var(--bg); }
.choice-option:has(input:checked) { border-color: var(--blue); background: rgba(0,61,255,0.04); }
.choice-option input[type="radio"] { width: auto; accent-color: var(--blue); }

.choice-other .other-input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--grey);
  padding: 4px 8px;
  font-size: 14px;
  background: transparent;
  min-height: auto;
}

.choice-other .other-input:disabled { opacity: 0.4; }

.survey-textarea {
  width: 100%;
  padding: 12px var(--pad);
  border: var(--border);
  font-family: var(--font-ui);
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
}

.survey-actions { margin-top: 20px; display: flex; align-items: center; gap: 12px; }
.feedback-success { color: var(--blue); font-family: var(--font-ui); font-weight: 600; }

/* ── Admin: Article List ── */
.admin-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--pad); padding: var(--pad); }

.article-list { max-height: calc(100vh - 140px); overflow-y: auto; }

#editor-card {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  position: sticky;
  top: 73px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--pad);
  border: var(--border);
  margin-bottom: -1px;
  cursor: pointer;
  background: var(--white);
  transition: background 0.1s;
}

.list-item:hover { background: var(--bg); }
.list-item.selected { background: #EEF; border-color: var(--blue); }
.list-item-title { font-family: var(--font-ui); font-size: 14px; font-weight: 500; flex: 1; }
.list-item-meta { display: flex; align-items: center; gap: 8px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.live { background: var(--blue); }
.status-dot.draft { background: var(--grey); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px var(--pad);
  font-family: var(--font-ui);
  color: var(--grey);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 24px;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-ui);
  font-size: 14px;
  z-index: 100;
  animation: fadeInUp 0.3s;
}

@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Floating Feedback Button ── */
.feedback-fab {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--blue);
  color: var(--white);
  padding: 14px 28px;
  border: none;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
}

.feedback-fab:hover { opacity: 0.9; }
.feedback-fab:active { transform: translateX(-50%) scale(0.97); }
.feedback-fab.done {
  background: var(--black);
  pointer-events: none;
  opacity: 0.7;
}

/* ── Feedback Modal ── */
.feedback-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.feedback-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.feedback-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 51;
  background: var(--white);
  border-top: var(--border);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}

.feedback-modal.open { transform: translateY(0); pointer-events: auto; }

.feedback-modal-header {
  position: sticky;
  top: 0;
  background: var(--white);
  border-bottom: 1px solid #EEE;
  padding: 16px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
}

.feedback-modal-header h2 { font-size: 18px; }

.feedback-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  color: var(--grey);
}

.feedback-modal-close:hover { color: var(--black); }

.feedback-modal-body {
  padding: var(--pad) var(--pad) 32px;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Mobile-optimized survey elements */
.scale-btn {
  min-width: 48px;
  min-height: 48px;
}

.choice-option {
  min-height: 48px;
}

.survey-textarea {
  font-size: 16px; /* prevents iOS zoom */
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .login-box { padding: 32px var(--pad); }
  .container { padding: 0 12px; }
}

@media (min-width: 600px) {
  .feedback-modal {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    max-width: 540px;
    width: calc(100% - 32px);
    max-height: 85vh;
    border: var(--border);
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .feedback-modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
}
