/*
Theme: Label4
Description: A4用紙にクリックポスト伝票を4面付け印刷するウェブアプリ
Author: Preferred-Inc
Version: 2.0
License: MIT License
*/

:root {
  --bg: #f0f2f5;
  --header-bg: #1a1a2e;
  --header-text: #e0e0e0;
  --accent: #4361ee;
  --card-border: #e0e0e0;
  --dropzone-border: #c0c4cc;
  --dropzone-hover: #4361ee;
  --dropzone-bg: #f8f9fc;
  --dropzone-icon: #9ca3af;
  --footer-bg: #1a1a2e;
  --footer-text: #9ca3af;
  --shadow-hover: 0 4px 12px rgba(67, 97, 238, 0.15);
  --radius: 8px;
  --transition: 0.2s ease;
}

html,
body {
  font: 14px/1.5 'BIZ UDPGothic', 'MS PGothic', sans-serif;
  box-sizing: border-box;
  background-color: var(--bg);
  color: #333;
}

*,
*:before,
*:after {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

#wrapper {
  display: flex;
  flex-direction: column;
  width: 100dvw;
  min-height: 100dvh;
}

/* Header */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  width: 100%;
  height: 48px;
  padding: 0 12px;
  background-color: var(--header-bg);
  color: var(--header-text);
  gap: 12px;
}

.header-left {
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.file-info {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#current-file:empty::before {
  content: '\9078\629E\3055\308C\3066\3044\307E\305B\3093';
}

.header-right {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}

.clickpost-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: #e63946;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  transition: background-color var(--transition);
}

.clickpost-link:hover {
  background-color: #d62839;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--header-text);
  font-size: 14px;
  cursor: pointer;
  transition: background-color var(--transition);
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Content area: scrollable, contains print pages */
#content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Print page: A4 aspect ratio container */
.print-page {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 210 / 297;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 4px;
  overflow: hidden;
}

/* Form slots - 4-up layout (default) */
.print-page form {
  position: relative;
  width: 50%;
  aspect-ratio: 210 / 297;
  overflow: clip;
}

/* 2-up layout */
#content[data-layout="2"] .print-page form {
  width: 100%;
  height: 50%;
  aspect-ratio: auto;
}

#content[data-layout="2"] .print-page form:nth-child(n+3) {
  display: none;
}

/* Canvas */
.print-page form canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
}

#content[data-layout="2"] .print-page form canvas {
  width: 100%;
  height: 200%;
}

/* Page badge */
.page-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  font-size: 10px;
  color: #999;
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Slot remove button */
.slot-remove {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition);
}

.slot-remove:hover {
  background: #e63946;
}

form.selected .slot-remove {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Form interactions */
.print-page form input[type="file"] {
  display: none;
}

.print-page form label {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 4px;
  opacity: 1;
  cursor: pointer;
  transition: opacity var(--transition);
}

.print-page form.selected label {
  opacity: 0;
}

.print-page form.selected:active label {
  opacity: 1;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 2px dashed var(--dropzone-border);
  border-radius: var(--radius);
  background-color: var(--dropzone-bg);
  transition: border-color var(--transition), background-color var(--transition), box-shadow var(--transition);
}

.dropzone:hover {
  border-color: var(--dropzone-hover);
  background-color: #eef1ff;
  box-shadow: var(--shadow-hover);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--dropzone-icon);
  transition: color var(--transition);
}

.dropzone:hover .dropzone-inner {
  color: var(--accent);
}

.dropzone-inner i {
  font-size: 28px;
}

.dropzone-inner span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Page actions */
#page-actions {
  display: flex;
  justify-content: center;
  padding: 8px 0 16px;
}

.btn-add-page {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: 2px dashed var(--dropzone-border);
  border-radius: var(--radius);
  background: #fff;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-add-page:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.saved-counter {
  font-size: 13px;
  font-weight: 700;
  color: #22c55e;
  margin-left: 12px;
}

/* AdSense slot */
#ad-slot {
  max-width: 640px;
  margin: 16px auto 0;
  padding: 0 16px;
}

/* About (SEO section) */
#about {
  padding: 24px 16px;
  max-width: 640px;
  margin: 0 auto;
}

#about h2 {
  font-size: 16px;
  color: #1a1a2e;
  margin-bottom: 12px;
}

#about p {
  font-size: 13px;
  color: #555;
  line-height: 1.8;
  margin-bottom: 16px;
}

#about dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#about dt {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a2e;
  grid-column: span 1;
}

#about dt i {
  color: var(--accent);
  margin-right: 4px;
}

#about dd {
  font-size: 12px;
  color: #666;
  line-height: 1.7;
  margin: 0 0 8px;
  grid-column: span 1;
}

#about h3 {
  font-size: 14px;
  color: #1a1a2e;
  margin: 16px 0 8px;
}

.carrier-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.carrier-list li {
  font-size: 12px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: #555;
}

@media (max-width: 480px) {
  #about dl {
    grid-template-columns: 1fr;
  }
}

/* Recommend (affiliate) */
#recommend {
  padding: 16px 16px 24px;
  max-width: 640px;
  margin: 0 auto;
}

#recommend h3 {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 12px;
}

.recommend-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.recommend-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  color: #333;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.recommend-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.recommend-card i {
  font-size: 22px;
  color: var(--accent);
}

.recommend-title {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.recommend-desc {
  font-size: 10px;
  color: #999;
  text-align: center;
}

@media (max-width: 480px) {
  .recommend-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* FAQ */
#faq {
  padding: 0 16px 24px;
  max-width: 640px;
  margin: 0 auto;
}

#faq h3 {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 12px;
}

#faq details {
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: #fff;
}

#faq summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #333;
}

#faq summary:hover {
  color: var(--accent);
}

#faq details p {
  padding: 0 16px 12px;
  font-size: 12px;
  color: #666;
  line-height: 1.8;
}

/* PWA install banner */
.pwa-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 12px 16px;
  background: var(--header-bg);
  color: #fff;
  font-size: 13px;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pwa-banner.show {
  display: flex;
}

.pwa-banner button {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.pwa-banner .pwa-dismiss {
  background: transparent;
  color: #999;
  font-size: 18px;
  padding: 4px 8px;
}

/* Footer nav (carrier links) */
#footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

#footer-nav a {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

#footer-nav a:hover {
  text-decoration: underline;
}

/* Share buttons */
#share {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 16px 20px;
  max-width: 640px;
  margin: 0 auto;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  transition: opacity var(--transition);
}

.share-btn:hover {
  opacity: 0.85;
}

.share-x {
  background: #000;
}

.share-line {
  background: #06c755;
}

/* Footer */
#footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  min-height: 32px;
  padding: 8px;
  background-color: var(--footer-bg);
  color: var(--footer-text);
  font-size: 11px;
}

#footer a {
  color: var(--footer-text);
  text-decoration: none;
}

#footer a:hover {
  color: #e0e0e0;
}

.footer-sep {
  margin: 0 8px;
  opacity: 0.4;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal.active {
  display: flex;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  border: none;
  background: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}

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

.modal-content h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.modal-content ol {
  margin: 0 0 16px 20px;
  line-height: 2;
  color: #555;
}

.modal-content ol i {
  color: var(--accent);
  margin: 0 2px;
}

.modal-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background-color: #f0fdf4;
  border-radius: 6px;
  font-size: 13px;
  color: #166534;
}

.modal-note i {
  color: #22c55e;
}

.modal-carriers {
  margin-top: 10px;
  font-size: 11px;
  color: #999;
  text-align: center;
}

.modal-shortcuts {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 11px;
  color: #999;
}

.modal-shortcuts kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  background: #f0f2f5;
  border: 1px solid #ddd;
  border-radius: 3px;
}

/* Drag & drop state */
body.dragging .dropzone {
  border-color: var(--accent);
  background-color: #eef1ff;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Loading state */
.dropzone.loading {
  border-color: var(--accent);
  background-color: #eef1ff;
}

.dropzone.loading .dropzone-inner {
  color: var(--accent);
}

/* Toast notifications */
#toast-container {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 8px 20px;
  border-radius: 6px;
  background: #333;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: #166534; }
.toast-error { background: #991b1b; }

/* Stats badge */
#stats-badge {
  display: none;
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: #9ca3af;
}

/* Swap active state */
form.swap-active {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  border-radius: 4px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card-border: #333;
    --dropzone-border: #444;
    --dropzone-bg: #1e1e1e;
    --dropzone-icon: #666;
  }

  body { color: #e0e0e0; }

  .print-page {
    background: #1e1e1e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .dropzone:hover {
    background-color: #252540;
  }

  .page-badge {
    background: rgba(30, 30, 30, 0.8);
    color: #666;
  }

  .btn-add-page {
    background: #1e1e1e;
    color: #999;
    border-color: #444;
  }

  #about, #about h2, #about h3 { color: #e0e0e0; }
  #about p, #about dd { color: #aaa; }
  .carrier-list li { background: #1e1e1e; border-color: #333; color: #aaa; }
  #faq details { background: #1e1e1e; border-color: #333; }
  #faq summary { color: #ddd; }
  #faq details p { color: #aaa; }
  #faq h3 { color: #e0e0e0; }
  .recommend-card { background: #1e1e1e; border-color: #333; color: #ddd; }
  .recommend-desc { color: #777; }
  .modal-content { background: #1e1e1e; color: #e0e0e0; }
  .modal-content h2 { color: #e0e0e0; }
  .modal-content ol { color: #aaa; }
  .modal-close { color: #666; }
  .modal-close:hover { color: #ddd; }
  .modal-note { background: #162316; color: #6ee7b7; }
  .modal-shortcuts kbd { background: #333; border-color: #555; color: #ccc; }
}
