/* ============================================================
   BOSwriter – Main CSS
   Brand-Color: #FF7100
   ============================================================ */

:root {
  --brand:        #FF7100;
  --brand-dark:   #d95f00;
  --brand-light:  #fff3e8;
  --bg:           #f7f7f8;
  --surface:      #ffffff;
  --border:       #e2e2e5;
  --text:         #1a1a1a;
  --text-muted:   #6b7280;
  --danger:       #dc2626;
  --success:      #16a34a;
  --warning:      #d97706;
  --info:         #2563eb;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-dot {
  width: 10px; height: 10px;
  background: var(--brand);
  border-radius: 50%;
  display: inline-block;
}
.brand-dot.large { width: 18px; height: 18px; }

.navbar-links { display: flex; gap: .25rem; flex: 1; }

.nav-link {
  padding: .35rem .75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .9rem;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--brand); font-weight: 600; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.btn-logout {
  padding: .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .8rem;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

/* ---- Main Content ---- */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ---- Flash Messages ---- */
.flash-container { margin-bottom: 1rem; }

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: .5rem;
}
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #14532d; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a5f; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}
.card-body { padding: 1.25rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--brand);
}
.btn-secondary:hover { background: var(--brand-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: .85rem; padding: 0; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,113,0,.12);
}
textarea { resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }
.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; font-size: .9rem; }
.form-check input { width: auto; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: .75rem; }
.checkbox-item { display: flex; align-items: center; gap: .4rem; font-size: .9rem; cursor: pointer; }
.checkbox-item input { width: auto; }

.radio-group { display: flex; flex-direction: column; gap: .75rem; }
.radio-item { display: flex; align-items: flex-start; gap: .5rem; font-size: .9rem; cursor: pointer; }
.radio-item input { width: auto; margin-top: .2rem; }

.input-sm { padding: .3rem .6rem; font-size: .85rem; }
.input-narrow { max-width: 120px; }
.inline-form { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; flex: 1; }
.page-header-actions { display: flex; gap: .5rem; }

/* ---- Table ---- */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left;
  padding: .6rem 1rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }
.table-compact th, .table-compact td { padding: .5rem .875rem; }
.row-inactive td { opacity: .5; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #14532d; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #78350f; }
.badge-info    { background: #dbeafe; color: #1e3a5f; }
.role-admin    { background: #ffe4cc; color: #7c2d12; }
.role-editor   { background: #e0e7ff; color: #3730a3; }
.role-partner  { background: #f3f4f6; color: #374151; }
.role-custom   { background: #f3f4f6; color: #374151; }
.user-badge    { padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; justify-content: center; }
.page-info { font-size: .85rem; color: var(--text-muted); }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state p { margin-bottom: 1rem; }

/* ---- Text helpers ---- */
.text-muted { color: var(--text-muted); }
.section-label { font-size: .85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }

/* ---- Spinner ---- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Login ---- */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 1.8rem; font-weight: 800; margin-top: .5rem; }
.login-subtitle { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }
.login-form .form-group { margin-bottom: .875rem; }

/* ---- Mode Switcher ---- */
.mode-switcher {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.mode-btn:hover { border-color: var(--brand); color: var(--brand); }
.mode-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ---- Output review notice ---- */
.output-review-notice {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: #78350f;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: .5rem .75rem;
  margin-bottom: .75rem;
}

/* ---- Translate label ---- */
.translate-lang-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* ---- Workflow Steps ---- */
.step-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .95rem;
}
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.workflow-step { margin-bottom: 1rem; }
.step-action .card-body { display: flex; flex-direction: column; gap: .75rem; }

.btn-lg { padding: .7rem 1.25rem; font-size: 1rem; justify-content: center; }

.action-divider {
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: .1rem 0;
}

.translate-inline { display: flex; flex-direction: column; gap: .6rem; }
.select-full { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; background: var(--surface); color: var(--text); }
.select-inline { padding: .35rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; background: var(--surface); color: var(--text); }
.deepl-hint-small { font-size: .78rem; color: #78350f; margin-top: .25rem; padding: .4rem .6rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; }

/* ---- Tool Layout ---- */
.tool-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .tool-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: .75rem;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}
.upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
}
.upload-label svg { color: var(--brand); }

.format-toggle {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: .5rem;
  font-size: .82rem;
  color: var(--text-muted);
}
.format-toggle label { display: flex; align-items: center; gap: .3rem; cursor: pointer; }
.format-toggle input { width: auto; }

.divider-text {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  margin: .5rem 0;
  position: relative;
}
.divider-text::before, .divider-text::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--border);
}
.divider-text::before { left: 0; }
.divider-text::after { right: 0; }

.char-info {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .4rem;
}

.quota-grid {
  display: flex;
  gap: .75rem;
  margin-top: .5rem;
}
.quota-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.quota-label-small {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.quota-numbers {
  font-size: .78rem;
  color: var(--text-muted);
}
.quota-bar-mini {
  height: 4px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.quota-bar-mini-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s;
}
.quota-bar-mini-fill.warning { background: var(--warning); }
.quota-bar-mini-fill.danger  { background: var(--danger); }

/* Prompt list */
.prompt-category { margin-bottom: 1rem; }
.prompt-category-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--brand);
  margin-bottom: .4rem;
}
.prompt-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .88rem;
  transition: background .12s;
}
.prompt-item:hover { background: var(--bg); }
.prompt-item input { width: auto; flex-shrink: 0; }

/* Action bar */
.action-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.translate-controls { display: flex; align-items: center; gap: .5rem; }
.translate-controls select { width: auto; padding: .4rem .6rem; font-size: .85rem; }
.output-actions { display: flex; gap: .5rem; margin-left: auto; }
.deepl-hint { font-size: .82rem; margin-bottom: .75rem; }

/* Output */
.output-card .card-body { min-height: 200px; }
.output-placeholder {
  color: var(--text-muted);
  font-size: .9rem;
  padding: 2rem;
  text-align: center;
}
#outputText {
  width: 100%;
  border: none;
  resize: vertical;
  font-family: var(--font);
  font-size: .9rem;
  color: var(--text);
  outline: none;
  min-height: 300px;
}

/* Diff */
.diff-card { margin-top: 1rem; }
#diffView ins { background: #dcfce7; text-decoration: none; }
#diffView del { background: #fee2e2; text-decoration: line-through; }

/* History Detail */
.meta-bar {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.diff-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.diff-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.diff-col-header {
  padding: .6rem 1rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.diff-pre {
  padding: 1rem;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font);
  max-height: 500px;
  overflow-y: auto;
}
.diff-view ins { background: #dcfce7; text-decoration: none; }
.diff-view del { background: #fee2e2; text-decoration: line-through; }

/* Tariff */
.tariff-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.tariff-name { font-size: 1.4rem; font-weight: 700; margin-bottom: .75rem; }
.quota-bar-wrap { margin-bottom: .5rem; }
.quota-label { font-size: .85rem; color: var(--text-muted); margin-bottom: .35rem; }
.quota-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.quota-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .3s;
}
.quota-bar-fill.warning { background: var(--warning); }
.quota-bar-fill.danger  { background: var(--danger); }
.reset-info { font-size: .8rem; margin-top: .35rem; }

/* Plan cards */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
}
.plan-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s;
  display: block;
}
.plan-card:has(.plan-radio:checked), .plan-card.selected {
  border-color: var(--brand);
}
.plan-card.current { border-color: var(--brand); background: var(--brand-light); }
.plan-card-inner { padding: .875rem; }
.plan-card input { display: none; }
.plan-label { font-weight: 700; font-size: 1rem; margin-bottom: .25rem; }
.plan-limit { font-size: .8rem; color: var(--text-muted); margin-bottom: .4rem; }
.plan-price { font-size: .9rem; font-weight: 600; color: var(--brand); }

.upgrade-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.upgrade-total { font-size: .95rem; }

/* Admin */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card.highlight { border-color: var(--brand); background: var(--brand-light); }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--brand); }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }

.admin-nav { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.upgrade-request-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .875rem 0;
  border-bottom: 1px solid var(--border);
}
.upgrade-request-item:last-child { border-bottom: none; }
.upgrade-request-info { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.upgrade-message { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; width: 100%; }
.upgrade-request-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.toggle-btn {
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.toggle-btn.active {
  background: #dcfce7;
  color: #14532d;
  border-color: #bbf7d0;
}

/* ---- Feedback Button ---- */
.btn-feedback {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-feedback:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  width: 100%;
  max-width: 480px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 .25rem;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .875rem; }
.modal-footer {
  display: flex;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.feedback-hint {
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--brand-light);
  border-radius: var(--radius);
  padding: .5rem .75rem;
}

/* ---- Radio group ---- */
.radio-group { display: flex; flex-direction: column; gap: .375rem; }
.radio-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  cursor: pointer;
}

/* ---- Quota section label ---- */
.quota-section-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: .75rem;
  margin-bottom: .4rem;
}
