@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #f8fafc;
  /* Slate-50 */
  --card: #ffffff;
  --text: #1e293b;
  /* Slate-800 */
  --sub: #64748b;
  /* Slate-500 */
  --border: #e2e8f0;
  /* Slate-200 */

  /* Brand Colors: Indigo/Violet */
  --accent: #4f46e5;
  /* Indigo-600 */
  --accent-strong: #4338ca;
  /* Indigo-700 */
  --accent-light: #e0e7ff;
  /* Indigo-100 */

  --muted: #cbd5e1;
  --success: #10b981;
  /* Emerald-500 */
  --success-strong: #059669;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gradient-start: #6366f1;
  /* Indigo-500 */
  --gradient-end: #4f46e5;
  /* Indigo-600 */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.hero {
  padding: 40px 20px;
  text-align: center;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid white;
  border-radius: 24px;
  margin-bottom: 32px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 8px 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 32px;
  margin-top: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(15, 23, 42, 0.12);
  border-color: rgba(226, 232, 240, 0.8);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

label {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  transition: all 0.3s ease;
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 3px rgba(37, 99, 235, 0.2);
}

.checkboxes {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

button {
  padding: 16px 24px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--accent) 100%);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  min-width: 180px;
  letter-spacing: 0.5px;
}

button:hover {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.loading {
  position: relative;
  color: transparent;
  background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 100%);
}

button.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin: -10px 0 -10px;
  border: 3px solid white;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--sub);
  font-size: 14px;
}

#preview-card {
  margin-top: 24px;
  background: white;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

#preview-card pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "SFMono-Regular", ui-monospace, monospace;
  background: #f8fafc;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  line-height: 1.6;
  font-size: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.input-group textarea {
  flex: 1;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  border: 2px solid var(--border);
  min-width: 50px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.icon-btn .icon {
  font-size: 20px;
}

.icon-btn:hover {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  border-color: #c5cfd9;
}

.icon-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0.05);
}

.icon-btn.recording {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #dc2626;
  animation: pulse 1s infinite;
  border-color: var(--danger);
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);
}

.icon-btn.recording .btn-text::after {
  content: '...';
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.hint {
  font-size: 13px;
  color: var(--sub);
  margin: 4px 0 0;
  font-style: italic;
}

#logo-preview {
  margin-top: 8px;
}

#logo-preview img {
  max-width: 200px;
  max-height: 80px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  background: white;
}

.foto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.foto-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #f8fafc;
}

.foto-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.foto-item input {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.foto-item .remove-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.foto-item .remove-btn:hover {
  background: #dc2626;
}

/* Upgrade Modal */
.upgrade-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.upgrade-modal-content {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.upgrade-modal-content h2 {
  margin: 0 0 12px;
  color: var(--text);
}

.upgrade-modal-content p {
  color: var(--sub);
  margin: 0 0 24px;
}

.upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.upgrade-btn {
  display: block;
  padding: 16px 20px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  text-align: center;
  transition: transform 0.2s;
}

.upgrade-btn.starter {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
}

.upgrade-btn.pro {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: white;
}

.upgrade-btn:hover {
  transform: translateY(-2px);
}

.upgrade-btn small {
  display: block;
  opacity: 0.9;
  font-weight: 400;
  font-size: 13px;
  margin-top: 4px;
}

.upgrade-modal-content button {
  width: 100%;
  background: var(--muted);
  color: var(--text);
}

/* PRO Features */
.pro-badge {
  display: inline-block;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-left: 8px;
}

.pro-feature {
  border: 2px solid #7c3aed;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.template-btn {
  padding: 16px;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.template-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
}

#history-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  background: #f1f5f9;
  border-color: var(--accent);
}

.history-item-title {
  font-weight: 600;
  color: var(--text);
}

.history-item-meta {
  font-size: 13px;
  color: var(--sub);
  margin-top: 4px;
}

/* Signature Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.modal:not([hidden]) {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#signature-canvas {
  display: block;
  background: white;
  border-radius: 8px;
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  button {
    width: 100%;
  }

  .preview-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #preview-card button {
    width: 100%;
  }

  .input-group {
    flex-direction: column;
  }

  .icon-btn {
    width: 100%;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  #signature-canvas {
    width: 100%;
    height: 150px;
  }
}