/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f6fa; color: #2d3436; line-height: 1.6; }
a { color: #c0392b; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Variables ── */
:root {
  --red: #c0392b;
  --red-dark: #962d22;
  --red-light: #fdf2f2;
  --en-bg: #ebf5fb;
  --en-border: #2980b9;
  --ptbr-bg: #fef9e7;
  --ptbr-border: #f39c12;
  --tip-bg: #eafaf1;
  --tip-border: #27ae60;
  --card-shadow: 0 2px 8px rgba(0,0,0,.08);
  --radius: 10px;
}

/* ── Layout ── */
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.container-wide { max-width: 1200px; }

/* ── Navbar ── */
.navbar { background: var(--red); color: #fff; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.navbar-inner { max-width: 1200px; margin: 0 auto; padding: .75rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.navbar-brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; font-size: 1.1rem; }
.navbar-brand:hover { text-decoration: none; }
.brand-logo { font-size: 1.5rem; background: rgba(255,255,255,.15); padding: .1rem .4rem; border-radius: 6px; }
.navbar-links { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.navbar-links a { color: rgba(255,255,255,.9); font-size: .9rem; }
.navbar-links a:hover { color: #fff; text-decoration: none; }
.navbar-user { color: rgba(255,255,255,.8); font-size: .9rem; }
.btn-logout { background: rgba(255,255,255,.15); color: #fff !important; padding: .3rem .8rem; border-radius: 20px; font-size: .85rem; }
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ── Auth Page ── */
.auth-body { background: linear-gradient(135deg, #c0392b 0%, #962d22 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-container { width: 100%; max-width: 420px; padding: 1rem; }
.auth-brand { text-align: center; color: #fff; margin-bottom: 1.5rem; }
.auth-logo { font-size: 3rem; background: rgba(255,255,255,.15); display: inline-block; padding: .5rem 1rem; border-radius: 12px; margin-bottom: .5rem; }
.auth-brand h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.auth-brand p { opacity: .85; font-size: .95rem; }
.auth-card { background: #fff; border-radius: var(--radius); padding: 1.5rem; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.tab-nav { display: flex; border-bottom: 2px solid #eee; margin-bottom: 1.5rem; }
.tab-btn { flex: 1; padding: .7rem; background: none; border: none; font-size: 1rem; cursor: pointer; color: #888; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: .9rem; color: #666; }
.auth-footer { text-align: center; color: rgba(255,255,255,.6); font-size: .85rem; margin-top: 1rem; }

/* ── Cards & Forms ── */
.card { background: #fff; border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--card-shadow); margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .9rem; color: #444; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: .6rem .8rem; border: 1.5px solid #ddd; border-radius: 7px;
  font-size: .95rem; transition: border-color .2s; font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--red); }
.form-group small { color: #888; font-size: .8rem; display: block; margin-top: .2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; flex-wrap: wrap; }
.section-title { font-size: 1rem; color: var(--red); font-weight: 700; margin: 1.5rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px solid #eee; }
.required { color: var(--red); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.2rem; border-radius: 7px; font-size: .95rem; font-weight: 600; cursor: pointer; border: none; transition: all .2s; text-decoration: none !important; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-secondary { background: #f0f0f0; color: #444; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; color: #fff; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-xs { padding: .25rem .6rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.8rem; font-size: 1rem; }

/* ── Alerts ── */
.alert { padding: .75rem 1rem; border-radius: 7px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fdf2f2; border: 1px solid #e74c3c; color: #c0392b; }
.alert-success { background: #eafaf1; border: 1px solid #27ae60; color: #1e8449; }

/* ── Page Header ── */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; color: #2d3436; }
.page-header p { color: #666; margin-top: .3rem; }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; }
.text-muted { color: #666; }

/* ── Dashboard Negotiations Grid ── */
.negotiations-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.neg-card { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); overflow: hidden; transition: transform .2s, box-shadow .2s; }
.neg-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.neg-card-header { background: var(--red-light); padding: 1rem; border-bottom: 1px solid #f0dede; }
.neg-step-badge { font-size: .8rem; font-weight: 700; color: var(--red); margin-bottom: .4rem; }
.neg-title { font-size: 1rem; font-weight: 700; color: #2d3436; }
.neg-card-body { padding: 1rem; }
.neg-meta { font-size: .88rem; color: #555; margin-bottom: .4rem; }
.neg-step-progress { display: flex; gap: 4px; margin: .8rem 0; }
.step-dot { width: 14px; height: 14px; border-radius: 50%; background: #ddd; }
.step-dot.done { background: #27ae60; }
.step-dot.active { background: var(--red); ring: 2px solid var(--red); }
.neg-current-step { font-size: .85rem; color: var(--red); font-weight: 600; }
.neg-card-footer { padding: .75rem 1rem; border-top: 1px solid #f0f0f0; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.3rem; margin-bottom: .5rem; }
.empty-state p { color: #666; margin-bottom: 1.5rem; }

/* ── Quick Links ── */
.quick-links { margin-top: 2rem; }
.quick-links h3 { font-size: 1.1rem; color: #444; margin-bottom: 1rem; }
.quick-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.quick-link-card { display: flex; gap: 1rem; background: #fff; border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--card-shadow); transition: all .2s; align-items: flex-start; color: inherit; }
.quick-link-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); text-decoration: none; }
.ql-icon { font-size: 1.8rem; flex-shrink: 0; }
.quick-link-card strong { display: block; margin-bottom: .2rem; }
.quick-link-card p { font-size: .85rem; color: #666; margin: 0; }

/* ── Negotiation View ── */
.neg-view-header { background: #fff; border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--card-shadow); margin-bottom: 1rem; }
.neg-view-title { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.neg-view-title h2 { font-size: 1.3rem; }
.back-link { font-size: .9rem; color: #888; white-space: nowrap; }
.neg-view-meta { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; font-size: .88rem; color: #555; }

/* ── Step Nav ── */
.step-nav { display: flex; background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); margin-bottom: 1.5rem; overflow-x: auto; }
.step-tab { display: flex; flex-direction: column; align-items: center; padding: .8rem .6rem; flex: 1; min-width: 100px; font-size: .78rem; font-weight: 600; color: #999; border-bottom: 3px solid transparent; text-decoration: none !important; transition: all .2s; white-space: nowrap; }
.step-tab:hover { color: var(--red); background: var(--red-light); }
.step-tab.active { color: var(--red); border-bottom-color: var(--red); background: var(--red-light); }
.step-tab.done { color: #27ae60; }
.step-tab.locked { color: #ccc; }
.step-num { font-size: 1.2rem; margin-bottom: .15rem; }
.step-label { line-height: 1.2; text-align: center; }

/* ── Section Intro ── */
.section-intro { background: #fff; border-left: 4px solid var(--red); padding: 1rem 1.2rem; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 1.5rem; box-shadow: var(--card-shadow); }
.section-intro h3 { font-size: 1.1rem; margin-bottom: .4rem; color: var(--red); }
.section-intro p { color: #555; font-size: .95rem; }

/* ── Template Card ── */
.template-card { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); margin-bottom: 1.5rem; overflow: hidden; }
.template-card-header { padding: 1rem 1.2rem; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .5rem; }
.template-card-header h4 { font-size: 1rem; color: #2d3436; margin-bottom: .3rem; }
.canal-badge { font-size: .78rem; background: #f0f0f0; color: #666; padding: .2rem .6rem; border-radius: 20px; }
.scenario-box { background: #f8f9fa; border-left: 3px solid #aaa; padding: .7rem 1rem; margin: 0 1.2rem; border-radius: 0 5px 5px 0; font-size: .88rem; color: #555; }

/* ── Template Panels ── */
.template-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 1rem 1.2rem; gap: 1rem; }
@media (max-width: 768px) { .template-panels { grid-template-columns: 1fr; } }
.template-panel { border-radius: 8px; overflow: hidden; border: 1.5px solid #ddd; }
.panel-en { border-color: var(--en-border); }
.panel-ptbr { border-color: var(--ptbr-border); }
.panel-header { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; border-bottom: 1px solid rgba(0,0,0,.08); }
.panel-en .panel-header { background: #d6eaf8; }
.panel-ptbr .panel-header { background: #fdebd0; }
.panel-flag { font-size: 1.1rem; }
.panel-lang { font-weight: 700; font-size: .85rem; flex: 1; }
.template-text { padding: .8rem; font-size: .85rem; line-height: 1.7; white-space: pre-wrap; word-wrap: break-word; font-family: inherit; overflow: visible; }
.panel-en .template-text { background: var(--en-bg); }
.panel-ptbr .template-text { background: var(--ptbr-bg); }

/* ── Copy Button ── */
.copy-btn { padding: .3rem .7rem; font-size: .78rem; font-weight: 700; border: none; border-radius: 5px; cursor: pointer; transition: all .2s; }
.panel-en .copy-btn { background: var(--en-border); color: #fff; }
.panel-en .copy-btn:hover { background: #1a5276; }
.panel-ptbr .copy-btn { background: var(--ptbr-border); color: #fff; }
.panel-ptbr .copy-btn:hover { background: #ca6f1e; }
.copy-btn.copied { background: #27ae60 !important; }
.copy-btn-sm { background: #6c757d; color: #fff; padding: .25rem .6rem; font-size: .78rem; border: none; border-radius: 5px; cursor: pointer; margin-top: .5rem; }

/* ── Tip Box ── */
.tip-box { display: flex; gap: .75rem; background: var(--tip-bg); border-left: 3px solid var(--tip-border); padding: .9rem 1.2rem; margin: 0 0 0; font-size: .88rem; color: #1e8449; border-radius: 0 0 var(--radius) var(--radius); }
.tip-box-standalone { border-radius: var(--radius); margin-bottom: 1.5rem; }
.tip-icon { font-size: 1.2rem; flex-shrink: 0; }

/* ── Step Actions ── */
.step-actions { text-align: center; padding: 1.5rem 0; }
.complete-badge { display: inline-block; background: #eafaf1; color: #1e8449; padding: 1rem 2rem; border-radius: 10px; font-weight: 700; font-size: 1.1rem; border: 2px solid #27ae60; }

/* ── Mandarin Grid ── */
.mandarin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.mandarin-card { background: #fff; border-radius: var(--radius); padding: 1rem; box-shadow: var(--card-shadow); display: flex; gap: 1rem; align-items: flex-start; border-left: 4px solid var(--red); }
.mandarin-num { background: var(--red); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.mandarin-char { font-size: 1.8rem; font-weight: 700; color: #2d3436; line-height: 1; margin-bottom: .3rem; }
.mandarin-pinyin { font-size: .9rem; color: #888; margin-bottom: .3rem; font-style: italic; }
.mandarin-meaning { font-size: .95rem; margin-bottom: .3rem; }
.mandarin-when { font-size: .82rem; color: #666; }

/* ── Fatal Errors ── */
.errors-list { display: flex; flex-direction: column; gap: 1rem; }
.error-card { background: #fff; border-radius: var(--radius); padding: 1.2rem 1.5rem; box-shadow: var(--card-shadow); display: flex; gap: 1.2rem; align-items: flex-start; border-left: 5px solid var(--red); }
.error-icon { font-size: 2rem; flex-shrink: 0; }
.error-num { font-size: .78rem; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: 1px; margin-bottom: .2rem; }
.error-title { font-size: 1rem; font-weight: 700; color: #2d3436; margin-bottom: .4rem; }
.error-desc { font-size: .9rem; color: #555; line-height: 1.6; }

/* ── Alternate Step Tab ── */
.step-tab-alt { border-bottom-color: transparent; }
.step-tab-alt .step-num { filter: grayscale(0); }
.step-tab-alt:hover { color: #e67e22; background: #fef9e7; }
.step-tab-alt.active { color: #e67e22; border-bottom-color: #e67e22; background: #fef9e7; }
.step-tab-alt.done { color: #e67e22; }

/* ── Alternate Flow Badge ── */
.alt-flow-badge { background: #fef9e7; border: 1.5px solid #f39c12; border-radius: var(--radius); padding: .85rem 1.2rem; margin-bottom: 1.5rem; display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: #7d6608; }
.alt-flow-badge strong { color: #ca6f1e; }

/* ── Contextual Inputs Panel ── */
.step-inputs-panel { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); margin-bottom: 1.5rem; overflow: hidden; }
.step-inputs-header { display: flex; align-items: center; gap: .75rem; padding: .85rem 1.2rem; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; }
.step-inputs-header h4 { font-size: .95rem; font-weight: 700; color: #2d3436; flex: 1; margin: 0; }
.inputs-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 700; padding: .25rem .7rem; border-radius: 20px; }
.inputs-badge-ok { background: #eafaf1; color: #1e8449; }
.inputs-badge-warn { background: #fef9e7; color: #ca6f1e; }
.inputs-hint { font-size: .82rem; color: #888; padding: .5rem 1.2rem .75rem; }
.step-inputs-form { padding: 1rem 1.2rem 1.2rem; }
.step-inputs-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
@media (max-width: 600px) { .step-inputs-fields { grid-template-columns: 1fr; } }
.step-inputs-fields .form-group { margin-bottom: 0; }
.step-inputs-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }

/* ── Inputs Summary (completed state) ── */
.inputs-summary { padding: .85rem 1.2rem; }
.summary-items { display: flex; flex-wrap: wrap; gap: .5rem .75rem; margin-bottom: .75rem; }
.summary-item { font-size: .82rem; color: #444; }
.summary-item strong { color: #2d3436; }
.summary-item span { color: #888; }

/* ── Step Nav Actions (back/forward) ── */
.step-nav-actions { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; flex-wrap: wrap; gap: .75rem; }
.step-progress-text { font-size: .88rem; color: #888; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .step-nav { gap: 0; }
  .step-tab { padding: .6rem .4rem; min-width: 60px; font-size: .7rem; }
  .step-label { display: none; }
  .neg-view-title { flex-direction: column; gap: .3rem; }
  .template-card-header { flex-direction: column; }
  .step-nav-actions { flex-direction: column; align-items: stretch; }
  .step-nav-actions .btn { justify-content: center; }
}