/*
File: css/styles.css
Purpose: Central stylesheet for the VAAP user interface, including panels, buttons, workflow states, PDF/review layout, modal dialogs, draggable windows, report windows, configuration forms, and debug/report display elements.
Project use: Referenced by index.html and shared by all VAAP UI modules so visual behavior and layout remain consistent across Google authorization, configuration, review, reporting, and manual-entry workflows.
*/
body {
  font-family: Arial, Helvetica, sans-serif;
  padding: 20px;
  background: #f0f0f0;
  color: #222;
}

header { margin-bottom: 16px; }

.panel {
  background: white;
  padding: 15px;
  margin-bottom: 16px;
  box-shadow: 0 4px 8px rgba(0,0,0,.1);
  border-radius: 4px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.toolbar label { display: inline-flex; gap: 6px; align-items: center; }

button { padding: 7px 12px; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

button.active-workflow {
  font-weight: 700;
  border: 3px solid #1a73e8;
  background: #e8f0fe;
  color: #174ea6;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.20);
}

button.active-workflow::before {
  content: "✓ ";
  font-weight: 700;
}


input, select { padding: 6px; }
select { min-width: 320px; }

.layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

#pdf-rendering-canvas {
  background: white;
  box-shadow: 0 4px 8px rgba(0,0,0,.1);
  max-width: 55%;
}

.side-panel {
  min-width: 350px;
  max-width: 500px;
  max-height: 1200px;
  overflow: auto;
}

.form-row { margin-bottom: 12px; }
.form-row label { font-weight: bold; display: block; margin-bottom: 4px; }
.form-row input { width: 100%; box-sizing: border-box; }

.debug-row {
  margin-bottom: 4px;
  font-size: 12px;
  border-bottom: 1px solid #eee;
  padding-bottom: 2px;
}
.debug-index { color: #888; }

pre#json-output {
  background: #f7f7f7;
  padding: 10px;
  font-size: 12px;
  overflow: auto;
  border: 1px solid #ccc;
}

.config-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.config-row {
  display: grid;
  gap: 12px;
  align-items: end;
}
.config-user-row {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}
.config-folder-row {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}
.config-highlight-row {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}
.config-grid label, .ce-inputs label { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 900px) {
  .config-user-row,
  .config-folder-row,
  .config-highlight-row {
    grid-template-columns: 1fr;
  }
}

.small-note { color: #555; font-size: 13px; }
.status-text { color: #444; }
.status-text.error, .error { color: #b00020; }
.status-text.ok { color: #146c2e; }
.current-file { font-weight: bold; }
.hidden { display: none; }
.ce-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 10px 0;
}
.ce-inputs.hidden { display: none; }

.startup-banner {
  background: #e8f5e9;
  border: 1px solid #4caf50;
  color: #1b5e20;
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}
.startup-banner.error {
  background: #ffebee;
  border-color: #c62828;
  color: #b00020;
}

.highlight-legend-panel {
  padding: 10px 15px;
}

.highlight-legend-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.highlight-legend-row h3 {
  margin: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}

.legend-swatch {
  width: 18px;
  height: 14px;
  display: inline-block;
  border: 1px solid #999;
}

.legend-swatch.patterned {
  background-image: repeating-linear-gradient(45deg, rgba(120,120,120,.45) 0 1px, transparent 1px 6px);
}

.legend-border-swatch {
  width: 18px;
  height: 14px;
  display: inline-block;
  border: 2px solid #000;
  background: white;
}

.checkbox-label {
  justify-content: center;
}

.legend-value {
  color: #555;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.85em;
}

.folder-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.folder-picker-row input {
  flex: 1;
  min-width: 220px;
}

.folder-picker-row button {
  white-space: nowrap;
}


.folder-config-block {
  gap: 7px;
}

.folder-config-block button {
  align-self: flex-start;
}

.selected-folder-name {
  padding: 7px 9px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  border-radius: 4px;
  min-height: 34px;
  word-break: break-word;
  white-space: pre-wrap;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  color: #222;
}

.selected-folder-name.missing-folder {
  color: #777;
  font-style: italic;
}


.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  z-index: 9999;
  pointer-events: auto;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  padding: 18px;
  max-height: 90vh;
  overflow: auto;
  pointer-events: auto;
}

.draggable-modal {
  position: absolute;
  top: 90px;
  left: 80px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
}

.modal-drag-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 12px -18px;
  padding: 12px 18px;
  background: #f3f3f3;
  border-bottom: 1px solid #ddd;
  border-radius: 6px 6px 0 0;
  cursor: move;
  user-select: none;
}

.modal-drag-handle h3 {
  margin: 0;
}

.drag-hint {
  color: #666;
  font-size: 12px;
  font-style: italic;
  white-space: nowrap;
}

.manual-entry-content {
  width: min(780px, 95vw);
}

.manual-entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.manual-entry-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: bold;
}

.manual-test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 14px;
  margin-top: 8px;
}

.manual-test-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-actions {
  justify-content: flex-end;
}

.folder-action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.folder-config-block input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  font-family: Consolas, Monaco, monospace;
}

.summary-report-window {
  position: fixed;
  right: 18px;
  top: 90px;
  width: min(960px, calc(100vw - 36px));
  max-height: 75vh;
  overflow: auto;
  z-index: 1200;
  border: 2px solid #666;
}

.summary-report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #ddd;
  margin: -4px -4px 10px -4px;
  padding-bottom: 8px;
}

.summary-report-header h3 {
  margin: 0;
}

.compact-toolbar {
  margin-top: 0;
  gap: 6px;
}

.summary-report-table-container {
  overflow: auto;
  max-height: 55vh;
  border: 1px solid #ddd;
  background: #fff;
}

.summary-report-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.summary-report-table th,
.summary-report-table td {
  border: 1px solid #ddd;
  padding: 5px 7px;
  vertical-align: top;
  white-space: nowrap;
}

.summary-report-table th {
  background: #f3f3f3;
  position: sticky;
  top: 0;
  z-index: 1;
}

.summary-sheet-links {
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
  background: #fafafa;
  font-size: 13px;
}

.summary-sheet-frame {
  width: 100%;
  height: 55vh;
  border: 0;
  background: #fff;
}

/* Summary Report non-modal window: movable via header, resizable via lower-right corner. */
.summary-report-window {
  resize: both;
  min-width: 420px;
  min-height: 280px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px);
  height: 70vh;
}

.summary-report-header {
  cursor: move;
  user-select: none;
}

.summary-report-header button,
.summary-report-header a {
  cursor: pointer;
}

.summary-report-window.dragging {
  opacity: 0.92;
}

.summary-report-table-container {
  max-height: none;
  height: calc(100% - 92px);
}

.summary-sheet-frame {
  height: calc(100% - 34px);
  min-height: 220px;
}

/* Configuration modal: movable popup with persisted position. */
.config-modal-content {
  width: min(1120px, 96vw);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

#config-panel.modal {
  background: rgba(0, 0, 0, 0.12);
}

/* Drive folder browser used instead of Google Picker. It uses OAuth Drive API calls only, so no frontend API key is needed. */
.drive-browser-content {
  width: min(980px, 95vw);
  height: min(680px, 90vh);
  display: flex;
  flex-direction: column;
}

.drive-browser-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.drive-browser-path {
  padding: 7px 8px;
  border: 1px solid #ddd;
  background: #fafafa;
  margin: 8px 0;
  border-radius: 4px;
  font-size: 13px;
}

.drive-browser-crumb {
  border: 0;
  background: transparent;
  color: #174ea6;
  text-decoration: underline;
  padding: 0 2px;
}

.drive-browser-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.drive-browser-left,
.drive-browser-right {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  overflow: auto;
  background: #fff;
}

.drive-browser-left h4,
.drive-browser-right h4 {
  margin: 0 0 8px 0;
}

.drive-browser-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drive-browser-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid #e5e5e5;
  background: #fff;
  border-radius: 3px;
  box-sizing: border-box;
}

.drive-browser-location-row {
  cursor: pointer;
}

.drive-browser-folder-row {
  background: #f8fbff;
}

.drive-browser-file-row {
  color: #555;
  background: #fafafa;
}

.drive-browser-item-name {
  overflow-wrap: anywhere;
}

.drive-browser-item-meta {
  color: #777;
  font-size: 11px;
  white-space: nowrap;
}

.drive-browser-item-actions {
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

.drive-browser-section-heading {
  margin: 10px 0 4px;
  color: #555;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .drive-browser-grid {
    grid-template-columns: 1fr;
  }
}
