/*
 * LivBase Signatures - Styles
 *
 * ACCESSIBILITY:
 * - Target audience: Thai users, potentially 60+ years old
 * - Minimum font size: 18px
 * - Minimum touch target: 48x48px
 * - Contrast ratio: 7:1 for body text (WCAG AAA)
 */

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

html, body {
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  color: #111827;
  background-color: #f3f4f6;
  min-height: 100vh;
}

/* Landing page */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.landing h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #111827;
}

/* App container */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid #d1d5db;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: #111827;
}

.header-logo {
  height: 32px;
  width: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  background: #f3f4f6;
  border-radius: 0.5rem;
  padding: 0.25rem;
  border: 1px solid #d1d5db;
}

.lang-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0.5rem 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  color: #374151;
}

.lang-btn.active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  border: 1px solid #d1d5db;
}

/* LINE button */
.btn-line {
  min-width: 48px;
  min-height: 48px;
  background: #06C755;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}

.btn-line:hover {
  background: #05a347;
}

.btn-line svg {
  width: 24px;
  height: 24px;
}

/* Main content */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* PDF container */
.pdf-container {
  background: #fff;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.pdf-toolbar {
  background: #f9fafb;
  border-bottom: 1px solid #d1d5db;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.pdf-page-info {
  font-size: 1.125rem;
  color: #111827;
  font-weight: 500;
}

.pdf-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdf-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0.75rem;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  color: #374151;
}

.pdf-btn:hover {
  background: #e5e7eb;
}

.pdf-btn svg {
  width: 24px;
  height: 24px;
}

.pdf-zoom {
  font-size: 1.125rem;
  font-weight: 500;
  color: #111827;
  padding: 0 0.5rem;
}

.pdf-divider {
  width: 1px;
  height: 2rem;
  background: #d1d5db;
  margin: 0 0.5rem;
}

.pdf-viewer {
  flex: 1;
  min-height: 0;
  background: #e5e7eb;
  text-align: center;
}

.pdf-viewer canvas {
  display: block;
  margin: 0 auto;
  box-shadow: none;
  border: none;
  outline: none;
}

/* Footer */
.footer {
  background: #fff;
  border-top: 1px solid #d1d5db;
  padding: 1rem;
  position: sticky;
  bottom: 0;
}

.footer-inner {
  max-width: 48rem;
  margin: 0 auto;
}

/* Buttons */
.btn {
  min-height: 48px;
  padding: 1rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
  width: 100%;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-primary:disabled {
  background: #d1d5db;
  color: #6b7280;
  border-color: #9ca3af;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
  border-color: #9ca3af;
}

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

.btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* Modal overlay */
.modal {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid #d1d5db;
  background: #f9fafb;
}

.modal-title {
  padding: 1.5rem 1rem;
  background: #f9fafb;
  border-bottom: 1px solid #d1d5db;
}

.modal-title p {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: #f3f4f6;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid #d1d5db;
  background: #fff;
}

/* Signature canvas */
.signature-wrapper {
  width: 100%;
  max-width: 40rem;
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border: 2px solid #6b7280;
  overflow: hidden;
}

#signature-canvas {
  width: 100%;
  height: 280px;
  touch-action: none;
}

.signature-hint {
  color: #374151;
  font-size: 1.125rem;
  margin-top: 1rem;
  font-weight: 500;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.spinner {
  width: 60px;
  height: 60px;
  border: 5px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

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

.loading-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

/* Success screen */
.success-screen {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.checkmark {
  width: 100px;
  height: 100px;
  margin-bottom: 2rem;
}

.checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 3;
  stroke-miterlimit: 10;
  stroke: #16a34a;
  fill: none;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: #16a34a;
  stroke-width: 3;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
}

@keyframes stroke {
  100% { stroke-dashoffset: 0; }
}

.success-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1rem;
}

.success-message {
  font-size: 1.25rem;
  color: #111827;
  text-align: center;
  max-width: 28rem;
  line-height: 1.6;
}

.success-btn {
  margin-top: 2.5rem;
}

/* Completed screen (already signed) */
.completed-screen {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.completed-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.completed-icon {
  width: 100px;
  height: 100px;
  margin-bottom: 2rem;
}

.completed-icon svg {
  width: 100%;
  height: 100%;
}

.completed-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: #16a34a;
  margin-bottom: 1rem;
}

.completed-message {
  font-size: 1.25rem;
  color: #111827;
  text-align: center;
  max-width: 28rem;
  line-height: 1.6;
  margin-bottom: 2.5rem;
}

.completed-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Error/Expired screen */
.error-screen {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.error-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.error-icon {
  width: 80px;
  height: 80px;
  background: #fef3c7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  border: 2px solid #fbbf24;
}

.error-icon svg {
  width: 40px;
  height: 40px;
  color: #d97706;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1rem;
}

.error-message {
  font-size: 1.25rem;
  color: #111827;
  text-align: center;
  max-width: 28rem;
  line-height: 1.6;
  margin-bottom: 2.5rem;
}

.error-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .error-actions {
    flex-direction: row;
  }
}

/* Initial loading screen */
.init-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

/* Hide LINE text on mobile */
@media (max-width: 639px) {
  .btn-line-text {
    display: none;
  }
}
