/**
 * Shared Template Preview Styles
 * 
 * This file contains the common CSS styles for rendering estimate template previews
 * across both index.html (landing page) and settings.html (settings page).
 * 
 * These styles handle:
 * - Preview container layout and controls
 * - Simple and Minimal template rendering
 * - Responsive mobile adjustments
 * - Brand color customization
 * 
 * Used in conjunction with:
 * - js/estimate-templates.js (template HTML generation)
 * - js/index-preview.js (landing page preview logic)
 * - js/settings-preview.js (settings page preview logic)
 */

/* Template Preview Section Styles */
.preview-template-container {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .preview-template-container {
    grid-template-columns: 320px 1fr;
    gap: 2.5rem;
    align-items: start;
  }
}

.preview-controls {
  background: rgba(15, 23, 42, 0.85);
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 1.5rem;
}

.preview-control-group {
  margin-bottom: 1.5rem;
}

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

.preview-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb;
  margin-bottom: 0.5rem;
}

.preview-input {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.5);
  color: #e5e7eb;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.2s;
}

.preview-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(15, 23, 42, 0.7);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.preview-color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.preview-color-picker {
  appearance: none;
  width: 56px;
  height: 56px;
  border-radius: 0.5rem;
  border: 2px solid rgba(148, 163, 184, 0.3);
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.preview-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 0.5rem;
}

.preview-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 0.5rem;
}

.preview-color-hex {
  width: 90px;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.5);
  color: #e5e7eb;
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  text-align: center;
  transition: all 0.2s;
}

.preview-color-hex:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(15, 23, 42, 0.7);
}

.preview-color-hint {
  font-size: 0.75rem;
  color: #9ca3af;
}

.preview-file-input {
  width: 100%;
  padding: 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.35);
  color: #e5e7eb;
  font-size: 0.85rem;
  cursor: pointer;
}

.preview-style-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.preview-style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.85rem 0.75rem;
  border: 2px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.5);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.preview-style-btn:hover {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.5);
  transform: translateY(-1px);
}

.preview-style-btn.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.preview-style-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e5e7eb;
}

.preview-style-desc {
  font-size: 0.7rem;
  color: #9ca3af;
}

.preview-template-wrapper {
  position: relative;
}

.preview-disclaimer {
  text-align: center;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  background: rgba(37, 99, 235, 0.08);
  border-radius: 0.5rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.preview-template {
  background: white;
  border-radius: 0.75rem;
  overflow: visible;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

/* Simple Template Styles */
.simple-preview-page {
  padding: 28px 32px;
  min-height: 800px;
}

.simple-preview-header {
  display: grid;
  grid-template-columns: 1.8fr 2.6fr 1.3fr;
  gap: 24px;
  align-items: stretch;
}

.preview-logo-placeholder {
  width: 100px;
  height: 100px;
  border: 2px dashed #e5e7eb;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #94a3b8;
  align-self: center;
}

.preview-template-logo {
  max-width: 100px;
  max-height: 100px;
  object-fit: contain;
}

.preview-template-business-name {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.preview-business-contact {
  font-size: 11px;
  color: #475569;
  line-height: 1.4;
}

/* Note: .simple-estimate-title styling is inline in the HTML to match settings.html */

.simple-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 30px 0 24px;
}

.simple-info-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 28px;
}

.simple-section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #111827;
  margin-bottom: 6px;
}

.simple-info-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  background: #ffffff;
}

.simple-table-header {
  background: #dee2e6;
  border-top: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
}

.simple-total-row {
  background: #f8f9fa;
}

.simple-footer-note {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
}

/* Minimal Template Styles */
.minimal-preview-page {
  padding: 32px;
}

.minimal-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 0;
}

.minimal-preview-header .preview-template-business-name {
  font-size: 26px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.preview-contact-info {
  font-size: 11px;
  color: #475569;
  letter-spacing: 0.5px;
  line-height: 1.5;
}

.minimal-divider {
  height: 16px;
  background: #000;
  margin: 32px 0;
}

.minimal-title-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}

.minimal-section {
  margin-bottom: 24px;
}

.accent-border-bottom {
  border-bottom: 4px solid #000;
  padding-bottom: 16px;
}

.preview-client-contact {
  font-size: 13px;
  color: #475569;
  line-height: 1.6;
}

.minimal-line-items {
  margin-bottom: 32px;
}

.minimal-footer {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* Responsive adjustments for preview templates */
@media (max-width: 768px) {
  .preview-template {
    max-width: none;
    width: min(650px, calc(100% - 0.75rem));
    margin: 0 auto;
    border-radius: 0.5rem;
  }

  .preview-template-wrapper {
    overflow-x: hidden;
    padding-bottom: 1rem;
  }

  .simple-preview-page,
  .minimal-preview-page {
    max-width: 100%;
    overflow: hidden;
    padding: 12px 12px !important;
  }

  .preview-template .simple-preview-header {
    grid-template-columns: minmax(45px, 0.6fr) minmax(120px, 1.3fr) minmax(90px, 0.9fr) !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .preview-template .simple-preview-header > div {
    justify-content: center;
    min-width: 0;
  }

  .preview-template .simple-preview-header > div:nth-child(2) {
    text-align: center;
  }

  .preview-template .simple-preview-header > div:last-child {
    text-align: right;
    align-items: flex-end;
  }

  .preview-template .simple-preview-header > div:last-child > div:first-child {
    font-size: 16px !important;
    letter-spacing: 0.8px !important;
  }

  .preview-template .simple-preview-header > div:last-child > div:not(:first-child) {
    font-size: 9px !important;
  }

  .preview-template-business-name {
    font-size: 10px !important;
    letter-spacing: 0.3px !important;
    line-height: 1.25 !important;
  }

  .preview-business-contact,
  .preview-contact-info,
  .preview-client-contact {
    font-size: 8px !important;
    line-height: 1.3 !important;
  }

  .simple-section-label,
  .minimal-section > div:first-child,
  .minimal-line-items > div:first-child {
    font-size: 8.5px !important;
  }

  .preview-logo-placeholder {
    width: 68px !important;
    height: 68px !important;
    font-size: 8px !important;
  }

  .preview-template .simple-preview-header .preview-logo-placeholder {
    width: 65px !important;
    height: 65px !important;
  }

  .preview-template .simple-preview-header .preview-template-logo {
    max-width: 65px !important;
    max-height: 65px !important;
  }

  .minimal-divider {
    height: 10px !important;
    margin: 18px 0 !important;
  }

  .simple-divider {
    margin: 18px 0 14px !important;
  }

  .minimal-title-row {
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .minimal-title-row > div:first-child {
    font-size: 18px !important;
  }

  .minimal-title-row > div:last-child {
    margin-left: auto;
    text-align: right;
    font-size: 10px !important;
    line-height: 1.4 !important;
  }

  .simple-info-card {
    padding: 8px 10px !important;
  }

  .simple-info-sections {
    gap: 10px !important;
    margin-bottom: 18px !important;
  }

  .preview-template .minimal-preview-header,
  .preview-template .minimal-title-row {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 12px !important;
  }

  .preview-template .minimal-title-row > div:last-child div {
    font-size: 9px !important;
  }

  .preview-template .minimal-section,
  .preview-template .minimal-line-items {
    padding: 0 12px 16px !important;
  }

  .preview-template .minimal-footer {
    padding: 0 12px 16px !important;
    font-size: 10px !important;
  }

  .preview-template .logo-placeholder,
  .preview-template .preview-logo {
    width: 65px !important;
    height: 65px !important;
    max-width: 65px !important;
    max-height: 65px !important;
    font-size: 8px !important;
  }

  /* Ensure tables stay within bounds */
  .simple-table-wrapper,
  .investment-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .simple-table-wrapper table,
  .investment-table table {
    min-width: 100%;
    table-layout: fixed;
  }

  .simple-table-wrapper th,
  .simple-table-wrapper td,
  .investment-table th,
  .investment-table td {
    white-space: normal;
    word-break: break-word;
    padding: 8px 6px;
    font-size: 10px;
  }

  .simple-table-wrapper th:first-child,
  .simple-table-wrapper td:first-child,
  .investment-table th:first-child,
  .investment-table td:first-child {
    width: 40%;
  }

  .simple-table-wrapper th:last-child,
  .simple-table-wrapper td:last-child,
  .investment-table th:last-child,
  .investment-table td:last-child {
    width: 24%;
  }

  .preview-template {
    transform: translateX(0);
  }
}

@media (max-width: 480px) {
  .preview-template {
    width: min(600px, calc(100% - 0.5rem));
    margin: 0 auto;
  }

  .simple-preview-page,
  .minimal-preview-page {
    padding: 10px 9px !important;
  }

  .preview-template .simple-preview-header {
    grid-template-columns: minmax(40px, 0.5fr) minmax(95px, 1.1fr) minmax(70px, 0.8fr) !important;
    gap: 6px !important;
  }

  .preview-template-business-name {
    font-size: 9px !important;
  }

  .preview-business-contact,
  .preview-contact-info {
    font-size: 7.5px !important;
  }

  .simple-section-label,
  .minimal-section > div:first-child,
  .minimal-line-items > div:first-child {
    font-size: 8px !important;
  }

  .simple-table-wrapper th,
  .simple-table-wrapper td,
  .investment-table th,
  .investment-table td {
    font-size: 9px !important;
    padding: 6px 6px !important;
  }

  .preview-template .minimal-preview-header,
  .preview-template .minimal-title-row {
    padding: 10px 9px !important;
    gap: 6px !important;
  }

  .preview-template .minimal-title-row > div:first-child {
    font-size: 16px !important;
  }

  .minimal-divider {
    height: 9px !important;
    margin: 12px 0 !important;
  }

  .preview-template .minimal-section,
  .preview-template .minimal-line-items {
    padding: 0 9px 12px !important;
  }

  .preview-template .minimal-footer {
    padding: 0 9px 12px !important;
    font-size: 9px !important;
  }
}
