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

body {
  font-family: "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  direction: rtl;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Upload Section */
.upload-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.upload-box {
  background: white;
  border-radius: 20px;
  padding: 60px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 100%;
  transition: transform 0.3s ease;
}

.upload-box:hover {
  transform: translateY(-5px);
}

.upload-box.dragover {
  background: #f0f4ff;
  border: 3px dashed #667eea;
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 25px 70px rgba(102, 126, 234, 0.4);
}

.upload-icon {
  width: 80px;
  height: 80px;
  color: #667eea;
  margin-bottom: 20px;
}

.upload-box h2 {
  font-size: 1.8rem;
  color: #333;
  margin-bottom: 15px;
}

.upload-box p {
  color: #666;
  margin-bottom: 25px;
  font-size: 1rem;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn svg {
  width: 20px;
  height: 20px;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

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

/* Viewer Section */
.viewer-section {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-spacer {
  flex: 1;
}

.page-info {
  font-weight: 600;
  color: #334155;
  padding: 0 10px;
}

/* Canvas Container */
.canvas-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 40px 20px;
  min-height: 600px;
  overflow: auto;
  direction: ltr;
  touch-action: pan-y pinch-zoom;
}

@media (max-width: 768px) {
  .canvas-container {
    padding: 20px 10px;
    min-height: 400px;
  }
}

.click-instruction {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #10b981;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease, pulse 2s ease-in-out infinite;
}

.click-instruction svg {
  width: 24px;
  height: 24px;
}

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.05);
  }
}

#pdfCanvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  cursor: crosshair;
  background: white;
  direction: ltr;
  touch-action: none;
}

@media (max-width: 768px) {
  #pdfCanvas {
    width: 100%;
    max-width: 100%;
  }
}

@media (min-width: 769px) {
  #pdfCanvas {
    width: auto;
  }
}

#signatureMarkers {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  pointer-events: none;
  display: flex;
  justify-content: center;
}

.signature-marker {
  position: absolute;
  border: 2px dashed #667eea;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 4px;
  pointer-events: all;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 768px) {
  .signature-marker {
    border: 3px dashed #667eea;
    min-width: 120px;
    min-height: 40px;
  }
}

.signature-marker img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.signature-marker .remove-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.2s;
}

.signature-marker:hover .remove-btn {
  opacity: 1;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 20px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px 30px;
  border-bottom: 2px solid #e2e8f0;
}

.modal-header h2 {
  color: #333;
  font-size: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  color: #64748b;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #334155;
}

.modal-body {
  padding: 30px;
}

.modal-body p {
  color: #64748b;
  margin-bottom: 15px;
  font-size: 1rem;
}

#signatureCanvas {
  width: 100%;
  height: 200px;
  border: 3px solid #e2e8f0;
  border-radius: 12px;
  cursor: crosshair;
  background: white;
  touch-action: none;
}

.signature-controls {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.color-picker,
.size-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker label,
.size-picker label {
  font-weight: 600;
  color: #334155;
}

#signatureColor {
  width: 50px;
  height: 35px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
}

#signatureSize {
  width: 100px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
  padding: 25px 30px;
  border-top: 2px solid #e2e8f0;
}

/* Email Input Styles */
.email-input-group {
  margin-bottom: 20px;
}

.email-input-group label {
  display: block;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.email-input-group input[type="email"],
.email-input-group input[type="text"],
.email-input-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: "Heebo", sans-serif;
  transition: border-color 0.2s;
}

.email-input-group input[type="email"]:focus,
.email-input-group input[type="text"]:focus,
.email-input-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.email-input-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* Responsive Design */
@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .toolbar {
    justify-content: center;
  }

  .toolbar-spacer {
    display: none;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .modal-content {
    margin: 20px;
  }

  .signature-controls {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Loading State */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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