/* ============================================================
   QuickAtWork — Shared Tool Shell Styles
   Used by all industry subdomain pages
   ============================================================ */

/* --- Google Fonts loaded via <link> in each page's <head> for non-blocking render --- */

/* --- CSS Custom Properties --- */
:root {
  --bg:          #FAF8F5;
  --surface:     #F2EDE6;
  --surface2:    #EBE4DA;
  --border:      #DDD5C8;
  --border-soft: #EDE6DC;
  --text-1:      #1C1917;
  --text-2:      #6B5E52;
  --text-3:      #9C8C80;
  --accent:      #C17F3A;
  --accent-dark: #7A4E18;
  --accent-pale: #F5EBD8;
  --white:       #FFFFFF;

  --nav-height:     52px;
  --sidebar-width:  230px;
  --ad-panel-width: 180px;
  --bottom-ad-height: 60px;

  --radius-input:  6px;
  --radius-card:   12px;
  --radius-modal:  20px;
  --radius-pill:   100px;

  --transition-hover:   200ms ease;
  --transition-card:    220ms ease;
  --transition-sidebar: 150ms ease;

  --font-heading: 'DM Sans', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
img, svg { display: block; max-width: 100%; }

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

/* --- Top Nav --- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.04);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  color: var(--text-1);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo span.accent { color: var(--accent-dark); }

.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.nav-industry {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-industry-emoji { font-size: 15px; }

.nav-spacer { flex: 1; }

.nav-usage {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
}

.nav-usage-text { font-weight: 500; white-space: nowrap; }

.usage-bar {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 400ms ease;
}

.btn-upgrade {
  padding: 5px 12px;
  background: var(--accent-pale);
  color: var(--accent-dark);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--transition-hover);
}

.btn-upgrade:hover { background: var(--accent); color: var(--white); }

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 100px;
  background: var(--surface2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background var(--transition-hover);
}

.nav-avatar:hover { background: var(--border); }

/* Mobile hamburger */
.nav-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-input);
  color: var(--text-2);
  transition: background var(--transition-hover);
}

.nav-menu-btn:hover { background: var(--surface2); }

/* --- Main Body (sidebar + workspace + ad panel) --- */
.main-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding-bottom: var(--bottom-ad-height);
}

/* --- Left Sidebar --- */
.left-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height) - var(--bottom-ad-height));
}

.sidebar-section {
  padding: 16px 0 8px;
}

.sidebar-category {
  padding: 0 16px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition-sidebar), border-color var(--transition-sidebar);
  border-left: 2px solid transparent;
  position: relative;
}

.sidebar-item:hover {
  background: var(--surface2);
  border-left-color: var(--border);
}

.sidebar-item.active {
  background: var(--white);
  border-left-color: var(--accent);
  color: var(--text-1);
  font-weight: 500;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 8px 16px;
}

.sidebar-quick-links {
  padding: 8px 0;
}

.sidebar-quick-links .sidebar-category {
  padding-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--transition-hover);
}

.sidebar-link:hover { color: var(--accent); }
.sidebar-link svg { flex-shrink: 0; }

/* --- Workspace --- */
.workspace {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
  min-width: 0;
}

.tool-header {
  margin-bottom: 20px;
}

.tool-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}

.tool-subtitle {
  font-size: 13px;
  color: var(--text-2);
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.04);
  margin-bottom: 16px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 16px;
}

/* Form elements */
.form-group {
  margin-bottom: 16px;
}

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

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-1);
  transition: border-color var(--transition-hover), box-shadow var(--transition-hover);
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239C8C80' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(193, 127, 58, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-3); }

/* Toggle / Radio row */
.form-toggle-row {
  display: flex;
  gap: 6px;
}

.toggle-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--transition-hover);
}

.toggle-btn:hover { border-color: var(--accent); color: var(--accent); }

.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

/* Grid layouts for forms */
.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* Run Button */
.btn-run {
  width: 100%;
  padding: 12px;
  background: var(--text-1);
  color: var(--white);
  border-radius: var(--radius-input);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
  cursor: pointer;
  border: none;
  transition: background var(--transition-hover), transform 100ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-run:hover { background: #2C2926; }
.btn-run:active { transform: scale(0.99); }

/* Secondary buttons */
.btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--white);
  cursor: pointer;
  transition: all var(--transition-hover);
}

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

.btn-accent {
  padding: 8px 16px;
  background: var(--accent);
  border-radius: var(--radius-input);
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  cursor: pointer;
  transition: background var(--transition-hover);
  border: none;
}

.btn-accent:hover { background: var(--accent-dark); }

/* Output card */
.output-card {
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.04);
  margin-bottom: 16px;
}

.output-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-soft);
}

.output-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.output-card-actions {
  display: flex;
  gap: 8px;
}

.btn-copy {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--white);
  cursor: pointer;
  transition: all var(--transition-hover);
}

.btn-copy:hover { border-color: var(--accent); color: var(--accent); }
.btn-copy.copied { border-color: #22C55E; color: #22C55E; }

.output-body {
  padding: 20px 24px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.6;
}

.output-mono {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}

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

.data-table th {
  background: var(--surface2);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-2);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface); }

.data-table td.highlight {
  color: var(--text-1);
  font-weight: 600;
}

.data-table td.accent-text { color: var(--accent); font-weight: 600; }

/* Result grid for KPI-style outputs */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: 16px;
  text-align: center;
}

.result-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 6px;
}

.result-value {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
}

.result-value.accent { color: var(--accent); }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #DCFCE7; color: #16A34A; }
.badge-warning { background: #FEF3C7; color: #D97706; }
.badge-error   { background: #FEE2E2; color: #DC2626; }
.badge-info    { background: var(--accent-pale); color: var(--accent-dark); }

/* Error display */
.error-box {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-input);
  padding: 12px 16px;
  font-size: 13px;
  color: #DC2626;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* Add item button */
.btn-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-input);
  font-size: 13px;
  color: var(--text-3);
  background: none;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-hover);
}

.btn-add-row:hover { border-color: var(--accent); color: var(--accent); }

/* Line items table */
.line-items-table { margin-bottom: 12px; }

.line-items-table .line-row {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.line-items-table .line-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-1);
  transition: border-color var(--transition-hover);
}

.line-items-table .line-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-remove-row {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-hover);
  flex-shrink: 0;
}

.btn-remove-row:hover { border-color: #EF4444; color: #EF4444; }

/* Syntax highlight colors */
.json-key     { color: #C17F3A; }
.json-string  { color: #22863A; }
.json-number  { color: #005CC5; }
.json-bool    { color: #E36209; }
.json-null    { color: #999; }

/* Diff output */
.diff-add    { background: #F0FDF4; color: #166534; display: block; padding: 2px 4px; }
.diff-remove { background: #FFF1F2; color: #9F1239; display: block; padding: 2px 4px; }
.diff-same   { display: block; padding: 2px 4px; color: var(--text-2); }

/* Tabs */
.tab-list {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-hover);
}

.tab-btn:hover { color: var(--text-1); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Right Ad Panel */
.right-ad-panel {
  width: var(--ad-panel-width);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height) - var(--bottom-ad-height));
}

.ad-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-align: center;
}

.ad-unit {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius-input);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: var(--text-3);
  font-size: 11px;
  text-align: center;
  gap: 6px;
}

.ad-unit-tall  { min-height: 200px; }
.ad-unit-short { min-height: 100px; }

/* Bottom Ad Bar */
.bottom-ad-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--bottom-ad-height);
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.bottom-ad-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  flex-shrink: 0;
}

.bottom-ad-unit {
  flex: 1;
  max-width: 728px;
  height: 40px;
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-3);
  margin: 0 auto;
}

/* ============================================================
   Responsive — Mobile (≤768px sidebar collapses to drawer)
   ============================================================ */

@media (max-width: 768px) {
  .left-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    box-shadow: 4px 0 24px rgba(28, 25, 23, 0.12);
  }

  .left-sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.4);
    z-index: 199;
  }

  .sidebar-overlay.open { display: block; }

  .nav-menu-btn { display: flex; }

  .right-ad-panel { display: none; }

  .workspace { padding: 16px; }

  .form-row-2,
  .form-row-3,
  .form-row-4 { grid-template-columns: 1fr; }

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

  .bottom-ad-bar { padding: 0 12px; }
}

@media (max-width: 480px) {
  .result-grid { grid-template-columns: 1fr; }
  .form-toggle-row { flex-wrap: wrap; }
}

/* Utility classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

/* Print styles for invoice/offer letter */
@media print {
  .top-nav, .left-sidebar, .right-ad-panel, .bottom-ad-bar,
  .btn-run, .card:not(.print-target), .no-print { display: none !important; }
  .print-target { box-shadow: none !important; border: none !important; }
  .workspace { padding: 0; }
}
