/* =====================================================
   通学路図作成ツール - スタイルシート
   Primary: #d97706 (Amber/Orange)
===================================================== */

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

:root {
  --primary: #d97706;
  --primary-dark: #b45309;
  --primary-light: #fef3c7;
  --primary-hover: #f59e0b;
  --bg: #f9fafb;
  --bg-panel: #ffffff;
  --bg-header: #1c1917;
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --print-scale: 1;
}

html, body {
  height: 100%;
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Meiryo', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

/* =====================================================
   Header
===================================================== */

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-header);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 100;
}

#header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--primary-light);
}

.header-icon {
  font-size: 20px;
}

#header-actions {
  display: flex;
  gap: 8px;
}

.btn-export {
  padding: 6px 14px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  background: transparent;
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-export:hover {
  background: var(--primary);
  color: #fff;
}

/* =====================================================
   App Body Layout
===================================================== */

#app-body {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* =====================================================
   Left Toolbar
===================================================== */

#toolbar {
  width: 140px;
  min-width: 140px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toolbar-section {
  margin-bottom: 8px;
}

.toolbar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 4px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 8px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-align: left;
}

.tool-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.tool-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.tool-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.tool-label {
  line-height: 1.2;
}

#node-type-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.node-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}

.node-type-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.node-type-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  font-weight: 600;
  color: var(--primary-dark);
}

.hint-text {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.7;
  padding: 4px 2px;
}

.hint-text p {
  margin-bottom: 2px;
}

/* =====================================================
   Canvas Area
===================================================== */

#canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  background-image:
    radial-gradient(circle, #cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: auto;
  position: relative;
}

#canvas-wrapper {
  box-shadow: var(--shadow-md);
  background: #fff;
  display: block;
  position: relative;
}

#main-svg {
  display: block;
  cursor: default;
  background: #fff;
}

#main-svg.cursor-crosshair {
  cursor: crosshair;
}

#main-svg.cursor-pointer {
  cursor: pointer;
}

#main-svg.cursor-delete {
  cursor: not-allowed;
}

/* =====================================================
   Right Panel
===================================================== */

#right-panel {
  width: 220px;
  min-width: 220px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.panel-section.hidden {
  display: none;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--primary-dark);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--primary-light);
}

.panel-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

.prop-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.prop-row:last-child {
  margin-bottom: 0;
}

.prop-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.prop-row input[type="text"],
.prop-row select {
  width: 100%;
  padding: 5px 8px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.12s;
  font-family: inherit;
}

.prop-row input[type="text"]:focus,
.prop-row select:focus {
  outline: none;
  border-color: var(--primary);
}

.prop-row input[type="color"] {
  width: 100%;
  height: 30px;
  padding: 2px 4px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  cursor: pointer;
  background: #fff;
}

.prop-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.prop-row span {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

/* =====================================================
   Print Size Settings
===================================================== */

#print-size-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.print-size-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.print-size-opt:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.print-size-opt input[type="radio"] {
  accent-color: var(--primary);
  flex-shrink: 0;
}

.print-preview-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.print-preview {
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.size-100  { width: 28px; height: 40px; }
.size-50   { width: 20px; height: 28px; }
.size-25   { width: 14px; height: 20px; }
.size-12   { width: 10px; height: 14px; }

.print-size-opt span {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
}

/* =====================================================
   SVG Element Styles (applied via JS as classes/attrs)
===================================================== */

.node-circle {
  transition: stroke 0.1s, stroke-width 0.1s;
}

.node-group:hover .node-circle {
  stroke-width: 2.5;
}

.node-group.selected .node-circle {
  stroke: var(--primary) !important;
  stroke-width: 3 !important;
}

.node-group.selected .node-emoji {
  filter: drop-shadow(0 0 3px rgba(217,119,6,0.6));
}

.path-line {
  transition: stroke 0.1s, stroke-width 0.1s;
}

.path-group.selected .path-line {
  stroke: var(--primary) !important;
  stroke-width: 4 !important;
}

.path-hit {
  cursor: pointer;
  fill: none;
  stroke: transparent;
  stroke-width: 12;
}

.text-el {
  cursor: pointer;
}

.text-el.selected {
  outline: 2px dashed var(--primary);
}

/* =====================================================
   Text Input Dialog
===================================================== */

#text-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#text-dialog.hidden {
  display: none;
}

#text-dialog-box {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 320px;
  box-shadow: var(--shadow-md);
}

.dialog-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

#text-dialog-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 14px;
  transition: border-color 0.12s;
}

#text-dialog-input:focus {
  outline: none;
  border-color: var(--primary);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-primary {
  padding: 7px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  padding: 7px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
}

.btn-secondary:hover {
  background: var(--bg);
}

/* =====================================================
   Print Styles
===================================================== */

@media print {
  /* Hide everything except the SVG canvas */
  #app-header,
  #toolbar,
  #right-panel,
  #text-dialog,
  #canvas-area {
    display: block !important;
  }

  body, html {
    margin: 0;
    padding: 0;
    height: auto;
    overflow: visible;
  }

  #app-header,
  #toolbar,
  #right-panel {
    display: none !important;
  }

  #app-body {
    display: block;
    height: auto;
    overflow: visible;
  }

  #canvas-area {
    display: block;
    background: none;
    overflow: visible;
    padding: 0;
    margin: 0;
  }

  #canvas-wrapper {
    display: block;
    box-shadow: none;
    page-break-inside: avoid;
    transform-origin: top left;
    transform: scale(var(--print-scale));
  }

  @page {
    size: A4;
    margin: 10mm;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== 関連ツールセクション ===== */
.related-tools {
  margin: 3rem auto;
  padding: 1.5rem;
  max-width: 900px;
  background: var(--bg-panel);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  text-align: center;
}
.related-tools h2 { font-size: 1.4rem; margin-bottom: 0.8rem; color: var(--primary); }
.related-tools p { color: #555; margin-bottom: 1rem; }
.tool-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.tool-card {
  display: inline-block; padding: 0.8rem 1.2rem;
  background: var(--primary-light); border: 1px solid var(--primary);
  border-radius: 10px; text-decoration: none; color: var(--primary);
  font-weight: 500; transition: all 0.2s;
}
.tool-card:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }
.more-tools a { color: var(--primary); text-decoration: none; }
.more-tools a:hover { text-decoration: underline; }
footer {
  text-align: center; padding: 1.5rem 0;
  background-color: #f1f5f9; color: #555;
  font-size: 0.9rem; border-top: 1px solid #e2e8f0; margin-top: 2rem;
}
.footer-nav a { color: var(--primary); text-decoration: none; margin: 0 0.5rem; }
.footer-nav a:hover { text-decoration: underline; }
