/* ===== Font Faces for Signature Preview ===== */
@font-face {
  font-family: 'Dancing Script';
  src: url('../assets/fonts/DancingScript-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Great Vibes';
  src: url('../assets/fonts/GreatVibes-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Caveat';
  src: url('../assets/fonts/Caveat-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Sacramento';
  src: url('../assets/fonts/Sacramento-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Pacifico';
  src: url('../assets/fonts/Pacifico-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'Homemade Apple';
  src: url('../assets/fonts/HomemadeApple-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

button {
  cursor: pointer;
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* ===== Header Bar ===== */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 16px;
  justify-content: space-between;
}

.header-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #4CAF50;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.15s;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.header-btn.btn-primary {
  background: #4CAF50;
  border-color: #4CAF50;
}

.header-btn.btn-primary:hover {
  background: #45a049;
}

/* Usage Display */
.usage-display {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.usage-display.usage-warning {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

.usage-display.usage-exceeded {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-email {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tier-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.tier-free {
  background: #9e9e9e;
  color: #fff;
}

.tier-pro {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.tier-business {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #fff;
}

/* ===== Drop Zone ===== */
#drop-zone {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  z-index: 50;
}

.drop-zone-content {
  text-align: center;
  padding: 40px;
}

.drop-zone-icon {
  font-size: 72px;
  margin-bottom: 20px;
  opacity: 0.8;
}

#drop-zone h1 {
  font-size: 32px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 12px;
}

.drop-zone-text {
  font-size: 18px;
  color: #555;
  margin-bottom: 8px;
}

.drop-zone-subtext {
  font-size: 14px;
  color: #888;
  margin-bottom: 30px;
}

#drop-zone.drag-over {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

#drop-zone.drag-over .drop-zone-content {
  transform: scale(1.02);
}

/* ===== Buttons ===== */
.btn-primary {
  background: #4CAF50;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
}

.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
}

/* ===== Workspace ===== */
#workspace {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 64px;
  display: flex;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;
}

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

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

#sidebar label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 6px;
  margin-top: 12px;
}

#sidebar input[type="text"],
#sidebar input[type="email"],
#sidebar input[type="password"],
#sidebar input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.15s;
}

#sidebar input:focus {
  outline: none;
  border-color: #4CAF50;
}

#sidebar input[type="range"] {
  width: 100%;
  margin: 8px 0;
}

#sidebar input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.font-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.font-preview-box {
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  text-align: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.font-preview-box:hover {
  border-color: #4CAF50;
  background: #f8fdf8;
}

.font-preview-box.selected {
  border-color: #4CAF50;
  background: #e8f5e9;
}

.signature-preview {
  margin-top: 12px;
  padding: 16px;
  background: #f9f9f9;
  border: 2px dashed #ddd;
  border-radius: 6px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.signature-preview img {
  max-width: 100%;
  max-height: 120px;
}

.panel-actions {
  margin-top: 16px;
}

.panel-actions button {
  width: 100%;
}

/* ===== Viewer Area ===== */
#viewer-area {
  flex: 1;
  overflow: auto;
  background: #e8e8e8;
  padding: 20px;
}

#pdf-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.pdf-page {
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
}

.pdf-page canvas {
  display: block;
}

.page-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.placed-element {
  position: absolute;
  cursor: move;
  pointer-events: auto;
  user-select: none;
}


.placed-element img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.placed-element:hover {
  outline: 2px solid #4CAF50;
}

.placed-element.selected {
  outline: 2px solid #4CAF50;
}

.placed-element .resize-handle {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 12px;
  height: 12px;
  background: #4CAF50;
  border-radius: 50%;
  cursor: nwse-resize;
}

.placed-element .element-delete {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: #f44336;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.placed-element:hover .element-delete,
.placed-element.selected .element-delete {
  opacity: 1;
}

/* ===== Action Bar ===== */
#action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 0 20px;
}

.action-bar-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

#action-bar .usage-display {
  color: #666;
  background: #f5f5f5;
}

/* ===== Loading Overlay ===== */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  color: #666;
  font-size: 14px;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.modal-close:hover {
  background: #f5f5f5;
  color: #333;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
}

.modal-tab {
  flex: 1;
  padding: 16px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-tab:hover {
  background: #f9f9f9;
}

.modal-tab.active {
  color: #4CAF50;
  box-shadow: inset 0 -2px 0 #4CAF50;
}

.auth-form {
  padding: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: #4CAF50;
}

.form-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: #666;
}

.link {
  color: #4CAF50;
  cursor: pointer;
  font-weight: 500;
}

.link:hover {
  text-decoration: underline;
}

/* ===== Upgrade Modal ===== */
.upgrade-content {
  padding: 32px;
  position: relative;
}

.upgrade-content h2 {
  font-size: 24px;
  margin-bottom: 8px;
  text-align: center;
}

.upgrade-limit-msg {
  text-align: center;
  color: #f44336;
  font-weight: 500;
  margin-bottom: 24px;
}

.upgrade-features {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.upgrade-features h3 {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.upgrade-features ul {
  list-style: none;
}

.upgrade-features li {
  padding: 6px 0;
  font-size: 14px;
  color: #444;
}

.upgrade-pricing {
  text-align: center;
  margin-bottom: 16px;
}

.upgrade-pricing .price {
  font-size: 36px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 16px;
}

.upgrade-pricing .price span {
  font-size: 16px;
  font-weight: 400;
  color: #666;
}

.upgrade-footer {
  text-align: center;
  font-size: 12px;
  color: #999;
}

/* ===== Toast Notifications ===== */
#toast-container {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 1002;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast.success {
  background: #4CAF50;
}

.toast.error {
  background: #f44336;
}

.toast.info {
  background: #2196F3;
}

.toast.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #sidebar {
    width: 240px;
  }
  
  .font-preview-grid {
    grid-template-columns: 1fr;
  }
  
  #user-email {
    max-width: 100px;
  }
  
  .usage-display {
    display: none;
  }
  
  #action-bar .usage-display {
    display: block;
  }
}

@media (max-width: 480px) {
  #sidebar {
    position: fixed;
    bottom: 64px;
    left: 0;
    right: 0;
    top: auto;
    height: 200px;
    width: 100%;
    border-right: none;
    border-top: 1px solid #e0e0e0;
    z-index: 90;
  }
  
  #workspace {
    bottom: 264px;
  }
  
  #drop-zone h1 {
    font-size: 24px;
  }
  
  .drop-zone-text {
    font-size: 16px;
  }
  
  #header {
    padding: 0 12px;
    gap: 8px;
  }
  
  .header-brand {
    font-size: 16px;
  }
}

/* Email Verification Banner */
.verification-banner {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  color: #78350f;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  position: relative;
}

.verification-banner .btn-small {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 4px;
  background: #78350f;
  color: #fbbf24;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.verification-banner .btn-small:hover {
  background: #451a03;
}

.verification-banner .btn-small:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
