/* ============================================================
   SVL PROPOSAL GENERATOR — Design System
   Bloomberg Terminal meets McKinsey report.
   No cards. No rounded corners. No shadows. No gradients.
   ============================================================ */

/* --- CSS Variables — Light Mode (default) --- */
:root {
  --navy:        #0A1628;
  --steel-blue:  #1B3A6B;
  --accent-blue: #2E7DD1;
  --gold:        #C8922A;
  --white:       #FFFFFF;
  --off-white:   #F8F9FA;
  --border:      #D1D5DB;
  --text:        #000000;
  --text-secondary: #000000;
  --bg:          #FFFFFF;
  --bg-alt:      #F8F9FA;
  --error:       #DC2626;
  --success:     #059669;

  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body:    'Helvetica Neue', Helvetica, Arial, sans-serif;

  --nav-height: 56px;
  color-scheme: light dark;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --navy:        #000000;
  --steel-blue:  #1B3A6B;
  --accent-blue: #5BA0E0;
  --gold:        #D4A43A;
  --white:       #FFFFFF;
  --off-white:   #0A0A0A;
  --border:      #2D3748;
  --text:        #FFFFFF;
  --text-secondary: #FFFFFF;
  --bg:          #000000;
  --bg-alt:      #0A0A0A;
  --error:       #F87171;
  --success:     #34D399;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

p {
  font-size: 14px;
  color: var(--text);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-small {
  font-size: 13px;
}

/* --- Navigation Bar --- */
.nav {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  background: var(--navy);
  padding: 0 32px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 48px;
  text-decoration: none;
}

.nav-logo-img {
  height: 32px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--white);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: border-color 0.15s;
}

.nav-links a:hover {
  text-decoration: none;
}

.nav-links a.active {
  color: var(--white);
  border-bottom-color: var(--gold);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-right a {
  font-size: 13px;
  color: var(--white);
  text-decoration: none;
}

.nav-right a:hover {
  color: var(--white);
  text-decoration: none;
}

/* --- Page Layout --- */
.page {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 40px 24px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin: 0;
}

.page-body {
  padding: 32px 40px;
}

/* --- Login Page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
}

.login-container {
  width: 400px;
  text-align: center;
}

.login-brand {
  margin-bottom: 48px;
}

.login-logo {
  height: 56px;
  width: auto;
  display: block;
}

.login-form {
  text-align: left;
}

.login-form .field-label {
  color: var(--white);
}

.login-form .field-input {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: var(--white);
}

.login-form .field-input:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.12);
}

.login-form .field-input::placeholder {
  color: rgba(255,255,255,0.6);
}

.login-footer {
  margin-top: 48px;
  font-size: 12px;
  color: var(--white);
  letter-spacing: 0.5px;
}

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

.btn:hover {
  filter: brightness(0.9);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.btn-gold:hover {
  background: #b5821f;
}

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

.btn-navy:hover {
  background: #162844;
}

[data-theme="dark"] .btn-navy {
  background: var(--steel-blue);
}

[data-theme="dark"] .btn-navy:hover {
  background: #143058;
}

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

.btn-outline:hover {
  border-color: var(--text-secondary);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--error);
  color: var(--error);
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--navy);
  white-space: nowrap;
  cursor: default;
}

.data-table thead th.sortable {
  cursor: pointer;
}

.data-table thead th.sortable:hover {
  color: var(--text);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:nth-child(even) {
  background: var(--bg-alt);
}

.data-table tbody tr:hover {
  background: var(--bg-alt);
}

.data-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
}

.data-table .col-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table .col-actions a,
.data-table .col-actions button {
  font-size: 13px;
  color: var(--accent-blue);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.data-table .col-actions a:hover,
.data-table .col-actions button:hover {
  text-decoration: underline;
}

/* --- Status Dots --- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
}

.status-draft .status-dot { background: var(--text-secondary); }
.status-ready .status-dot { background: var(--accent-blue); }
.status-sent .status-dot { background: var(--gold); }
.status-viewed .status-dot { background: var(--success); }

/* --- Stats Row --- */
.stats-row {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.stat-item {
  flex: 1;
  padding: 24px 32px;
  border-right: 1px solid var(--border);
}

.stat-item:last-child {
  border-right: none;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 6px;
}

/* --- Forms --- */
.field {
  margin-bottom: 20px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--accent-blue);
}

.field-textarea {
  resize: vertical;
  min-height: 80px;
}

.field-error {
  border-color: var(--error) !important;
}

.field-error-msg {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 20px;
}

.form-row .field {
  flex: 1;
}

/* --- Form Wizard Steps --- */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 40px 0;
  position: relative;
}

.wizard-progress-line {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 2px;
  background: var(--border);
}

.wizard-progress-fill {
  height: 100%;
  background: var(--navy);
  transition: width 0.3s;
}

.wizard-steps {
  display: flex;
  gap: 200px;
  position: relative;
  z-index: 1;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.wizard-step-num {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
}

.wizard-step.active .wizard-step-num {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}

.wizard-step.completed .wizard-step-num {
  border-color: var(--success);
  background: var(--success);
  color: var(--white);
}

.wizard-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.wizard-step.active .wizard-step-label {
  color: var(--text);
}

/* --- Wizard Form Panels --- */
.wizard-panel {
  display: none;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 0;
}

.wizard-panel.active {
  display: block;
}

.wizard-panel h2 {
  margin-bottom: 8px;
}

.wizard-panel .section-desc {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}

/* --- AI Toggle --- */
.ai-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.ai-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.ai-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.ai-toggle input {
  display: none;
}

.ai-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  transition: background 0.2s;
}

.ai-toggle input:checked + .ai-toggle-track {
  background: var(--accent-blue);
}

.ai-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--white);
  transition: transform 0.2s;
}

.ai-toggle input:checked ~ .ai-toggle-thumb {
  transform: translateX(20px);
}

.ai-toggle-status {
  font-size: 12px;
  color: var(--text-secondary);
}

/* --- Proposal Detail Layout --- */
.proposal-layout {
  display: flex;
  height: calc(100vh - var(--nav-height));
}

.proposal-sidebar {
  width: 280px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px;
  flex-shrink: 0;
}

.proposal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.proposal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.proposal-toolbar .btn {
  padding: 6px 14px;
  font-size: 13px;
}

.proposal-toolbar .spacer {
  flex: 1;
}

.proposal-preview {
  flex: 1;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.proposal-preview iframe {
  width: 90%;
  height: 95%;
  border: none;
  background: var(--bg);
}

.proposal-preview .empty-state {
  text-align: center;
  color: var(--text);
}

/* --- Sidebar Meta --- */
.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.sidebar-meta dt {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.sidebar-meta dd {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* --- Settings Sections --- */
.settings-section {
  margin-bottom: 48px;
}

.settings-section h2 {
  margin-bottom: 8px;
}

.settings-section .section-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}

.settings-grid {
  max-width: 600px;
}

/* --- Filter / Search Bar --- */
.table-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.table-controls .field-input {
  max-width: 280px;
}

.table-controls .field-select {
  max-width: 180px;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 80px 40px;
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  color: var(--text);
  margin-bottom: 24px;
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: border-color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--white);
}

/* --- Dark mode overrides for inline styles --- */
[data-theme="dark"] .login-page {
  background: var(--bg);
}

[data-theme="dark"] .login-form .field-input {
  background: rgba(255,255,255,0.06);
  border-color: var(--border);
}

[data-theme="dark"] .login-form .field-input:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.1);
}

[data-theme="dark"] .btn-outline {
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .btn-outline:hover {
  border-color: var(--text);
}

[data-theme="dark"] .page {
  background: var(--bg);
}

/* --- Loading Bar (thin animated line) --- */
.loading-bar-container {
  width: 100%;
  height: 3px;
  background: var(--border);
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: var(--accent-blue);
  width: 0%;
  transition: width 0.3s;
}

.loading-bar.indeterminate {
  width: 30%;
  animation: loading-slide 1.5s infinite ease-in-out;
}

@keyframes loading-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* --- Toast / Inline Messages --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  background: var(--steel-blue);
  z-index: 200;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.toast-error {
  background: var(--error);
}

.toast.toast-success {
  background: var(--success);
}

/* --- Keyboard Focus Styles --- */
.btn:focus-visible,
.field-input:focus-visible,
.field-select:focus-visible,
.field-textarea:focus-visible,
.settings-tab:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.nav-links a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* --- Utility --- */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .page-header,
  .page-body {
    padding-left: 24px;
    padding-right: 24px;
  }

  .stats-row {
    flex-wrap: wrap;
  }

  .stat-item {
    flex: 1 1 50%;
    border-bottom: 1px solid var(--border);
  }

  .proposal-layout {
    flex-direction: column;
  }

  .proposal-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 250px;
    overflow-y: auto;
  }

  .wizard-steps {
    gap: 80px;
  }

  .wizard-progress-line {
    width: 200px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .nav {
    padding: 0 16px;
  }

  .nav-links {
    gap: 0;
  }

  .nav-links a {
    padding: 8px 10px;
    font-size: 13px;
  }

  .settings-tabs {
    flex-wrap: wrap;
  }

  .data-table {
    font-size: 13px;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 10px 12px;
  }
}

@media (max-width: 768px) {
  .page-header,
  .page-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .stat-item {
    flex: 1 1 100%;
    padding: 16px 20px;
  }

  .stat-value {
    font-size: 24px;
  }

  .wizard-steps {
    gap: 40px;
  }

  .wizard-progress-line {
    width: 120px;
  }

  .wizard-step-label {
    font-size: 10px;
  }

  .proposal-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
  }

  .login-container {
    width: 90%;
    max-width: 400px;
  }

  .login-logo {
    height: 44px;
  }

  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .table-controls .field-input,
  .table-controls .field-select {
    max-width: 100%;
  }
}

/* --- Settings Tabs --- */
.settings-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.settings-tab {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: var(--text);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
}

.settings-tab:hover {
  color: var(--accent-blue);
}

.settings-tab.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  font-weight: 700;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

/* --- Print --- */
@media print {
  .nav,
  .proposal-toolbar,
  .theme-toggle,
  .toast,
  #emailCompose {
    display: none !important;
  }

  .page {
    padding-top: 0;
  }

  .proposal-sidebar {
    display: none;
  }

  .proposal-preview iframe {
    width: 100%;
    height: auto;
  }

  .page-body {
    padding: 16px;
  }

  .data-table {
    font-size: 12px;
  }

  .btn {
    display: none !important;
  }

  body {
    color: #000000;
    background: #FFFFFF;
  }
}
