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

body {
  font-family: "Arial", sans-serif;
  background: linear-gradient(135deg, #f61a1a 0%, #0f00e2 100%);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

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

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.mode-switcher {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 12px 24px;
  margin: 0 10px;
  cursor: pointer;
  border-radius: 25px;
  transition: all 0.3s ease;
  font-weight: bold;
  backdrop-filter: blur(10px);
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
}

.section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.section h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 1.8rem;
  text-align: center;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #555;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

/* .certificate-container {
  position: relative;
  display: inline-block;
  margin: 20px 0;
  border: 3px solid #667eea;
  border-radius: 10px;
  overflow: visible;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
} */

.certificate-container {
    position: relative;
    display: inline-block;
    margin: 20px 0;
    border: 3px solid #667eea;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.cert-wrapper {
    position: relative;
    display: inline-block;
    margin-left: 40px;
    margin-top: 40px;
    overflow: visible;
}

.cert-ruler-horizontal,
.cert-ruler-vertical {
  position: absolute;
  background: #e8e8e8;
  border: 1px solid #ccc;
  font-size: 9px;
  color: #666;
  z-index: 5;
  user-select: none;
}

.cert-ruler-horizontal {
  top: -30px;
  left: 0;
  right: 0;
  height: 30px;
  border-bottom: 2px solid #999;
}

.cert-ruler-vertical {
  left: -30px;
  top: 0;
  bottom: 0;
  width: 30px;
  border-right: 2px solid #999;
}

.guide-line {
  position: absolute;
  z-index: 15;
  cursor: move;
  pointer-events: auto;
}

.guide-line.horizontal {
  width: 100%;
  height: 1px;
  background: #00b8d4;
  box-shadow: 0 0 2px rgba(0, 184, 212, 0.8);
  left: 0;
  right: 0;
}

/* .guide-line.horizontal::before {
  content: "";
  position: absolute;
  left: -30px;
  top: -3px;
  width: 30px;
  height: 7px;
  background: #00b8d4;
  cursor: ns-resize;
} */

.guide-line.vertical {
  height: 100%;
  width: 1px;
  background: #00b8d4;
  box-shadow: 0 0 2px rgba(0, 184, 212, 0.8);
  top: 0;
  bottom: 0;
}
.guide-line.horizontal::before {
    content: '';
    position: absolute;
    left: -30px;
    top: -3px;
    width: 30px;
    height: 7px;
    background: #00b8d4;
    cursor: ns-resize;
    pointer-events: auto;
}

.guide-line.vertical::before {
    content: '';
    position: absolute;
    top: -30px;
    left: -3px;
    height: 30px;
    width: 7px;
    background: #00b8d4;
    cursor: ew-resize;
    pointer-events: auto;
}

/* .guide-line.vertical::before {
  content: "";
  position: absolute;
  top: -30px;
  left: -3px;
  height: 30px;
  width: 7px;
  background: #00b8d4;
  cursor: ew-resize;
} */
/* .guide-line {
    position: absolute;
    z-index: 15;
    cursor: move;
}

.guide-line.horizontal {
    width: 100%;
    height: 1px;
    background: #00b8d4;
    box-shadow: 0 0 2px rgba(0, 184, 212, 0.8);
}

.guide-line.horizontal::before {
    content: '';
    position: absolute;
    left: -30px;
    top: -3px;
    width: 30px;
    height: 7px;
    background: #00b8d4;
    cursor: ns-resize;
}

.guide-line.vertical {
    height: 100%;
    width: 1px;
    background: #00b8d4;
    box-shadow: 0 0 2px rgba(0, 184, 212, 0.8);
}

.guide-line.vertical::before {
    content: '';
    position: absolute;
    top: -30px;
    left: -3px;
    height: 30px;
    width: 7px;
    background: #00b8d4;
    cursor: ew-resize;
}  */

.guide-line:hover {
  background: #ff4081;
  box-shadow: 0 0 4px rgba(255, 64, 129, 0.8);
}

.guide-line:hover::before {
  background: #ff4081;
}

.ruler-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}

.certificate-image {
  max-width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}

.coordinate-marker {
  position: absolute;
  min-width: 200px;
  min-height: 60px;
  background: rgba(255, 71, 87, 0.3);
  border: 3px solid #ff4757;
  border-radius: 8px;
  cursor: move;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  animation: pulse 2s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #ff4757;
  font-size: 16px;
  user-select: none;
}

.coordinate-marker:hover {
  background: rgba(255, 71, 87, 0.4);
}

.resize-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #ff4757;
  border: 2px solid white;
  border-radius: 50%;
  cursor: nw-resize;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.resize-handle:hover {
  background: #ff3742;
  transform: scale(1.2);
}

.resize-handle.top-left {
  top: -6px;
  left: -6px;
  cursor: nw-resize;
}

.resize-handle.top-right {
  top: -6px;
  right: -6px;
  cursor: ne-resize;
}

.resize-handle.bottom-left {
  bottom: -6px;
  left: -6px;
  cursor: sw-resize;
}

.resize-handle.bottom-right {
  bottom: -6px;
  right: -6px;
  cursor: se-resize;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
  }
}

.canvas-container {
  text-align: center;
  margin: 20px 0;
}

#previewCanvas {
  border: 3px solid #667eea;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
}

.canvas-wrapper {
  position: relative;
  border: 3px solid #667eea;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin: 20px auto;
  max-width: 100%;
  background: #f8f9fa;
}

.canvas-viewport {
  width: 100%;
  height: 600px;
  overflow: hidden;
  position: relative;
  background: #ffffff;
}

.canvas-content {
  transform-origin: 0 0;
  transition: transform 0.1s ease-out;
  position: relative;
}

.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 2px solid #dee2e6;
}

.position-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 15px 0;
  max-width: 300px;
}

.ruler-tick {
  position: absolute;
  background: #666;
}

.cert-ruler-horizontal .ruler-tick {
  width: 1px;
  height: 6px;
  bottom: 0;
}

.cert-ruler-horizontal .ruler-tick.major {
  height: 10px;
}

.cert-ruler-vertical .ruler-tick {
  height: 1px;
  width: 6px;
  right: 0;
}

.cert-ruler-vertical .ruler-tick.major {
  width: 10px;
}

.ruler-label {
  position: absolute;
  font-size: 8px;
  color: #333;
  user-select: none;
}

.cert-ruler-horizontal .ruler-label {
  bottom: 12px;
  transform: translateX(-50%);
}

.cert-ruler-vertical .ruler-label {
  right: 2px;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.position-btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.position-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.position-btn:active {
  transform: translateY(0);
}

.position-btn.center-center {
  background: linear-gradient(45deg, #00b894, #00a085);
}

.zoom-btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.zoom-btn:active {
  transform: translateY(0);
}

#zoomLevel {
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  color: #333;
  min-width: 60px;
  text-align: center;
  border: 2px solid rgba(102, 126, 234, 0.3);
}

.btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  margin: 10px;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(-1px);
}

.btn-secondary {
  background: linear-gradient(45deg, #ff6b6b, #ee5a24);
}

.btn-success {
  background: linear-gradient(45deg, #00b894, #00a085);
}

.info-text {
  color: #666;
  font-style: italic;
  margin: 10px 0;
  text-align: center;
}

.coordinates-display {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
  font-family: monospace;
}

.box-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 10px;
}

.box-info div {
  background: #e9ecef;
  padding: 10px;
  border-radius: 6px;
  text-align: center;
}

.hidden {
  display: none;
}

.font-preview {
  margin-top: 15px;
  padding: 30px;
  border-radius: 8px;
  text-align: center;
  font-size: 24px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #dee2e6;
}

.font-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

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

.color-picker-group input[type="color"] {
  width: 60px;
  height: 40px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

.color-picker-group input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  font-family: monospace;
  font-size: 14px;
}

.size-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.size-input-group input[type="range"] {
  flex: 1;
}

.size-input-group input[type="number"] {
  width: 80px;
  padding: 8px 12px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  font-size: 14px;
}

.font-tabs {
  display: flex;
  border-bottom: 2px solid #dee2e6;
  margin-bottom: 20px;
}

.font-tab {
  flex: 1;
  padding: 12px 20px;
  background: #f8f9fa;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: #666;
  transition: all 0.3s ease;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.font-tab.active {
  background: #667eea;
  color: white;
}

.font-tab:hover {
  background: #5a6fd8;
  color: white;
}

.font-content {
  display: none;
}

.font-content.active {
  display: block;
}

.loaded-fonts-list {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 15px;
  margin-top: 15px;
  max-height: 200px;
  overflow-y: auto;
}

.font-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: white;
  margin-bottom: 8px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

.font-item:last-child {
  margin-bottom: 0;
}

.font-item-name {
  font-weight: bold;
  color: #333;
  flex: 1;
}

.font-item-remove {
  background: #ff4757;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.font-item-remove:hover {
  background: #ff3742;
}

.font-input-group {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.font-input-group > div {
  flex: 1;
}

.font-input-group button {
  padding: 12px 20px;
  height: fit-content;
}

@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .mode-btn {
    padding: 10px 20px;
    margin: 5px;
  }

  .section {
    padding: 20px;
  }

  .font-tabs {
    flex-direction: column;
  }

  .font-input-group {
    flex-direction: column;
    gap: 15px;
  }

  .font-input-group button {
    width: 100%;
  }
}
