/* Kitchify Smart Contract Generator – Magic Link flow */

/* View modes */
body.customer-view #admin-panel-wrap {
  display: none !important;
}

body.customer-view #main-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

body.customer-view .contract-paper-wrap {
  width: 100%;
}

#customer-view-actions.hidden {
  display: none !important;
}

#customer-view-actions:not(.hidden) {
  display: flex !important;
}

body.customer-view .admin-only {
  display: none !important;
}

body.customer-view .customer-only {
  display: block !important;
}

body.customer-view .customer-only.hidden {
  display: block !important;
}

body:not(.customer-view) .customer-only {
  display: none !important;
}

body.customer-view .contract-readonly {
  user-select: none;
  -webkit-user-select: none;
}

/* Left panel: modern sans-serif */
.admin-panel {
  font-family: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Right panel: scrollable from top to bottom */
.contract-paper-wrap {
  display: flex;
  justify-content: center;
  min-height: min-content;
  padding-bottom: 2rem;
}

/* Paper: 8.5" x 11" US letter, white, centered, subtle shadow – premium SaaS look */
.contract-paper {
  width: 100%;
  max-width: 8.5in;
  min-height: 11in;
  padding: 2rem 2.5rem;
  background: #fff;
  color: #1e293b;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  box-sizing: border-box;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06), 0 10px 25px -8px rgba(0, 0, 0, 0.12);
}

/* Header: logo top left */
.contract-header {
  margin-bottom: 0;
}

.contract-logo {
  width: auto;
}

/* Section cards: premium SaaS style */
.contract-card {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #f9fafb;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.contract-title {
  font-family: Inter, system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: left;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.admin-sig-image {
  max-width: 280px;
  max-height: 100px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
}

.contract-signature-placeholder {
  min-height: 120px;
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  color: #94a3b8;
  font-style: italic;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  padding-left: 0.75rem;
}

.contract-input-inline {
  font-size: inherit;
}

.contract-input-inline:focus {
  outline: none;
  border-color: #0f172a;
}

/* Customer View validation (bright red border + message) */
.contract-input-inline.contract-input-invalid,
.signature-pad.contract-input-invalid {
  border-color: #ef4444 !important; /* border-red-500 */
}

.contract-field-error {
  color: #ef4444;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: block;
}

.contract-section {
  margin-bottom: 0;
}

.contract-card .contract-heading {
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
}

.contract-heading {
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #111827;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
}

.contract-legal {
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.8125rem;
  color: #4b5563;
  margin: 0;
  text-align: justify;
}

.contract-label {
  font-weight: 600;
  color: #374151;
  margin-right: 0.35rem;
}

.contract-value {
  color: #1e293b;
}

.contract-value.empty {
  color: #94a3b8;
  font-style: italic;
}

.contract-grid {
  display: grid;
  gap: 0.25rem 1rem;
  grid-template-columns: 1fr;
}

.contract-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contract-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.contract-underline {
  flex: 1;
  border-bottom: 1px solid #cbd5e1;
  min-width: 8rem;
}

/* Simple initial line (Section 2 and Section 3) */
.contract-initial-simple {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.contract-initial-underline {
  border-bottom: 1px solid #334155;
  min-width: 12rem;
  display: inline-block;
}

.contract-addon {
  display: block;
}

.contract-addon.hidden {
  display: none !important;
}

/* Fine print: small, italic, muted gray */
.contract-fine-print {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.contract-fine-print-text {
  font-size: 0.7rem;
  line-height: 1.4;
  color: #64748b;
  font-style: italic;
  margin: 0;
  text-align: justify;
}

.signature-pad {
  display: block;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

.contract-signature-box {
  height: 2.5rem;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  background: #f8fafc;
}

.contract-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

/* Email Template Modal */
.email-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.email-modal-overlay.hidden {
  display: none !important;
}

.email-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.email-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
}

.email-modal-title {
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.email-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.email-modal-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.email-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.email-field {
  margin-bottom: 1rem;
}

.email-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.email-subject {
  font-size: 0.9375rem;
  color: #1e293b;
  margin: 0;
  padding: 0.5rem 0;
}

.email-body {
  font-size: 0.875rem;
  color: #334155;
  line-height: 1.6;
  white-space: pre-wrap;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 1rem;
}

.email-body a {
  color: #d97706;
  text-decoration: underline;
}

.email-body-preview {
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: #333333;
  line-height: 1.6;
  white-space: normal;
}

.email-body-preview a {
  font-weight: bold;
  color: #d97706;
  text-decoration: underline;
}

.btn-submit-contract:disabled {
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-submit-contract.btn-submit-loading .btn-submit-text::before {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: -0.2em;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.email-copy-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: #d97706;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.email-copy-btn:hover {
  background: #b45309;
}

/* Dark panel select arrow */
aside select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.25rem;
  padding-right: 2.25rem;
}
