/* ========================================
   Invoice Generator — Page & Form Styles
   ======================================== */

:root {
  --accent: #1a1a2e;
  --accent-light: rgba(26, 26, 46, 0.05);
  --accent-border: rgba(26, 26, 46, 0.15);
  --text: #111111;
  --text-secondary: #555;
  --text-tertiary: #888;
  --bg: #f0f0f3;
  --white: #ffffff;
  --border: #ddd;
  --border-focus: #1a1a2e;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --transition: 180ms ease;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Split Layout — balanced proportions */
.app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.form-panel {
  padding: 48px 48px;
  overflow-y: auto;
  max-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
}

.preview-panel {
  padding: 48px 48px;
  overflow-y: auto;
  max-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-sticky {
  position: sticky;
  top: 0;
  width: 100%;
  max-width: 560px;
}

.preview-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.preview-frame {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  aspect-ratio: 210 / 297; /* A4 ratio */
  width: 100%;
}

/* Form Header */
.form-header {
  margin-bottom: 36px;
}

.form-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.tagline {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-weight: 400;
}

.tagline a {
  font-weight: 600;
}

/* Sections */
.form-section {
  margin-bottom: 30px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Fields */
.field {
  margin-bottom: 16px;
}

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

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fafafa;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--white);
}

input::placeholder,
textarea::placeholder {
  color: #bbb;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Logo Upload */
.logo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 16px;
  position: relative;
}

.logo-upload:hover {
  border-color: var(--accent-border);
  background: var(--accent-light);
}

.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.logo-icon {
  font-size: 28px;
  color: #ccc;
  font-weight: 300;
  line-height: 1;
}

.logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.logo-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

.logo-thumb {
  max-width: 200px;
  max-height: 60px;
  object-fit: contain;
}

.logo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}

.logo-remove:hover {
  background: #fee;
  border-color: #fcc;
  color: #c00;
}

/* Color Picker */
.color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 3px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
}

.color-hex {
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Line Items */
.line-items-header {
  display: grid;
  grid-template-columns: 1fr 64px 80px 80px 32px;
  gap: 8px;
  padding: 10px 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 10px;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 64px 80px 80px 32px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.line-item-row input {
  padding: 8px 10px;
  font-size: 13px;
}

.line-item-amount {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  padding-right: 4px;
  color: var(--text);
}

.btn-remove-line {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: #ccc;
  font-size: 16px;
  transition: all var(--transition);
}

.btn-remove-line:hover {
  background: #fee;
  border-color: #fcc;
  color: #c00;
}

.btn-add {
  width: 100%;
  padding: 11px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

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

/* Totals Form */
.totals-form {
  max-width: 200px;
  margin-left: auto;
}

.totals-form input[type="number"] {
  width: 80px;
  text-align: right;
}

/* Advanced Toggle */
.btn-advanced {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 10px 0;
  font-family: inherit;
  transition: color var(--transition);
}

.btn-advanced:hover {
  color: var(--text);
}

#advancedArrow {
  display: inline-block;
  font-size: 10px;
  transition: transform var(--transition);
  margin-right: 6px;
}

#advancedArrow.open {
  transform: rotate(90deg);
}

.advanced-fields {
  padding-top: 16px;
}

.discount-row {
  display: flex;
  gap: 8px;
}

.discount-row select {
  flex: 1;
}

.discount-row input {
  width: 100px;
}

/* Download Button */
.form-actions {
  padding-top: 12px;
  padding-bottom: 44px;
}

.btn-download {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(26, 26, 46, 0.25);
}

.btn-download:hover {
  opacity: 0.92;
  box-shadow: 0 4px 16px rgba(26, 26, 46, 0.3);
}

.btn-download:active {
  transform: scale(0.98);
}

/* Responsive */
@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }
  .form-panel {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .preview-panel {
    max-height: none;
    padding: 28px 20px;
  }
  .preview-sticky {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .form-panel {
    padding: 24px 18px;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .line-items-header,
  .line-item-row {
    grid-template-columns: 1fr 56px 64px 64px 28px;
    gap: 4px;
  }
}

@media print {
  .form-panel,
  .preview-label {
    display: none !important;
  }
  .preview-panel {
    padding: 0;
  }
  .preview-frame {
    box-shadow: none;
    border-radius: 0;
    aspect-ratio: auto;
  }
  .app {
    display: block;
  }
}
