/* Tool Specific Styles */

.controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.status-text {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
}

.editor-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  margin-top: 2rem;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  background: white; /* Always white background for PDF unless we invert it */
  padding: 0;
  overflow: hidden;
  max-width: 100%;
}

#pdf-render-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Signature Overlay */
.sig-overlay {
  position: absolute;
  top: 50px;
  left: 50px;
  border: 2px dashed var(--md-sys-color-primary);
  cursor: move;
  user-select: none;
  touch-action: none;
  z-index: 10;
}

.sig-overlay img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Resizers */
.resizer {
  width: 12px;
  height: 12px;
  background: var(--md-sys-color-primary);
  position: absolute;
  border-radius: 50%;
}

.top-left { top: -6px; left: -6px; cursor: nwse-resize; }
.top-right { top: -6px; right: -6px; cursor: nesw-resize; }
.bottom-left { bottom: -6px; left: -6px; cursor: nesw-resize; }
.bottom-right { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* 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: 2000;
  backdrop-filter: blur(4px);
}

.modal-content {
  width: 90%;
  max-width: 800px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.sig-tools {
  padding: 1rem 1.5rem;
  background: var(--md-sys-color-surface-container-low);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tool-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.color-picker, .weight-picker {
  display: flex;
  gap: 0.5rem;
}

.color-opt {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s;
}

.color-opt.active {
  border-color: var(--md-sys-color-outline);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary);
  transform: scale(1.1);
}

.weight-opt {
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.weight-opt.active {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
}

.dot {
  background: var(--md-sys-color-on-surface);
  border-radius: 50%;
}
.v-thin { width: 4px; height: 4px; }
.v-medium { width: 8px; height: 8px; }
.v-thick { width: 14px; height: 14px; }

.canvas-container {
  flex: 1;
  padding: 1rem;
  background: var(--md-sys-color-surface-container-highest);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#signature-pad-canvas {
  background: white; /* Signature always on white */
  box-shadow: var(--md-sys-elevation-1);
  border-radius: 4px;
  cursor: crosshair;
  aspect-ratio: 1 / 1; /* 強制比例 */
  max-width: 100%;
  max-height: 100%;
}

.modal-footer {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

/* Floating Action Bar */
.action-bar-floating {
  position: sticky;
  bottom: 2rem;
  left: 50%;
  transform: translateX(0);
  background: var(--md-sys-color-surface-container-high);
  padding: 1rem 2rem;
  border-radius: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  box-shadow: var(--md-sys-elevation-3);
  z-index: 100;
  border: 1px solid var(--md-sys-color-outline-variant);
  margin-bottom: 2rem;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(var(--md-sys-color-background-rgb), 0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--md-sys-color-outline-variant);
  border-top: 4px solid var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

/* Page Controls */
.page-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--md-sys-color-secondary-container);
  padding: 0.5rem 1.5rem;
  border-radius: 2rem;
  color: var(--md-sys-color-on-secondary-container);
}

#page-info {
  font-size: 0.875rem;
  font-weight: 500;
}

.hidden { display: none !important; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* RWD */
@media (max-width: 768px) {
  .action-bar-floating {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    width: 90%;
    border-radius: 1rem;
  }
  
  .hide-mobile { display: none; }
}

@media (max-width: 480px) {
  .modal-content {
    width: 95%;
    height: 90vh;
  }
  
  .sig-tools { gap: 0.75rem; padding: 0.75rem; }
}
