/* ============================================
   LIGHT THEME DESIGN TOKENS
   ============================================ */
:root {
  --bg-page:       #f4f2f7;
  --bg-card:       #ffffff;
  --bg-card-hover: #faf8ff;
  --bg-input:      #f9f7fc;
  --border-color:  #e2d9f3;
  --border-active: #800080;
  --primary:       #800080;
  --primary-hover: #6a006a;
  --primary-glow:  rgba(128, 0, 128, 0.18);
  --accent-purple: #a020a0;
  --text-main:     #1a0a1a;
  --text-muted:    #6b5b7b;
  --text-dim:      #9b8aab;
  --success:       #059669;
  --radius-lg:     16px;
  --radius-md:     10px;
  --radius-sm:     6px;
  --shadow-card:   0 2px 12px rgba(128, 0, 128, 0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg:     0 8px 32px rgba(128, 0, 128, 0.14), 0 2px 8px rgba(0,0,0,0.06);
  --font-family:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 4px rgba(128, 0, 128, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-img {
  height: 40px;
  max-width: 160px;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
}

.brand-app-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
  background: rgba(128, 0, 128, 0.08);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(128, 0, 128, 0.15);
}

.nav-actions {
  display: flex;
  gap: 0.75rem;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.app-container {
  display: grid;
  grid-template-columns: 460px 1fr;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  gap: 1.75rem;
  padding: 1.75rem 2rem;
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   SIDEBAR PANEL
   ============================================ */
.sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 110px);
  box-shadow: var(--shadow-card);
}

@media (max-width: 1024px) {
  .sidebar {
    max-height: none;
  }
}

/* ============================================
   TAB NAVIGATION
   ============================================ */
.tabs-header {
  display: flex;
  background: #faf7ff;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  padding: 0.9rem 0.6rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(128, 0, 128, 0.04);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(128, 0, 128, 0.06);
  font-weight: 700;
}

/* ============================================
   TAB PANEL CONTENT
   ============================================ */
.tab-content {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.2rem;
}

.tab-panel.active {
  display: flex;
}

/* ============================================
   FORM CONTROLS
   ============================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="tel"]::placeholder,
input[type="url"]::placeholder {
  color: var(--text-dim);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--border-active);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23800080' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Hex Code Input Field */
.hex-input {
  width: 100px !important;
  padding: 0.45rem 0.65rem !important;
  font-family: 'Fira Code', 'Courier New', monospace !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  color: var(--primary) !important;
  background: #fdf8ff !important;
  border: 1.5px solid var(--border-color) !important;
  border-left: 3px solid var(--primary) !important;
  border-radius: var(--radius-sm) !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.hex-input:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-glow) !important;
  background: #fff !important;
}

input[type="color"] {
  -webkit-appearance: none;
  border: 2px solid var(--border-color);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  cursor: pointer;
  background: none;
  padding: 2px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

/* ============================================
   CUSTOM FILE UPLOAD DROPZONE
   ============================================ */
.file-upload-wrapper {
  position: relative;
  width: 100%;
}

.file-upload-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.file-upload-label {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-upload-wrapper:hover .file-upload-label,
.file-upload-input:focus + .file-upload-label {
  border-color: var(--primary);
  background: rgba(128, 0, 128, 0.04);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.file-upload-icon {
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

.file-upload-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
}

.file-upload-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-upload-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   TEMPLATE CARDS
   ============================================ */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.template-card {
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: var(--primary);
  background: rgba(128, 0, 128, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.template-card.selected {
  border-color: var(--primary);
  background: rgba(128, 0, 128, 0.07);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.template-card .icon {
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
  color: var(--primary);
}

.template-card .name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ============================================
   LOGO PRESET CARDS
   ============================================ */
.logo-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.logo-preset-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.logo-preset-card:hover {
  border-color: var(--primary);
  background: rgba(128, 0, 128, 0.04);
}

.logo-preset-card.active {
  border-color: var(--primary);
  background: rgba(128, 0, 128, 0.06);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.logo-preset-card img {
  max-height: 35px;
  max-width: 120px;
  object-fit: contain;
}

/* ============================================
   PREVIEW PANEL (RIGHT SIDE)
   ============================================ */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: var(--shadow-card);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.preview-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
  border-radius: 20px;
  font-weight: 700;
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.35; }
  100% { opacity: 1; }
}

/* ============================================
   EMAIL MOCKUP CANVAS
   ============================================ */
.email-mockup {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 2rem;
  border: 1px solid #e5e7eb;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
  color: #333;
}

.signature-stage {
  width: 100%;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.action-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.btn {
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  color: #ffffff;
  box-shadow: 0 3px 12px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-input);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================
   HTML SOURCE BOX
   ============================================ */
.source-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-card);
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.source-header label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

textarea.code-output {
  width: 100%;
  height: 160px;
  background: #faf7ff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #800080;
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  padding: 1rem;
  resize: vertical;
  line-height: 1.6;
}

textarea.code-output:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #ffffff;
  border: 1.5px solid var(--primary);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  color: var(--success);
  font-size: 1.2rem;
}

/* ============================================
   FOOTER CREDIT
   ============================================ */
.app-footer {
  text-align: center;
  padding: 1.25rem 2rem;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}

.app-footer strong {
  color: var(--primary);
  font-weight: 700;
}
