/* Style System for Imposition Calculator */

:root {
  /* Dark Theme Colors */
  --bg-app: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: #0b0f19;
  --bg-input-focus: #1e293b;
  
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --accent-primary: #38bdf8;       /* Cyan */
  --accent-primary-hover: #0ea5e9;
  --accent-primary-glow: rgba(56, 189, 248, 0.35);
  
  --accent-success: #34d399;       /* Emerald */
  --accent-success-glow: rgba(52, 211, 153, 0.25);
  
  --accent-highlight: #f43f5e;     /* Rose for Sheet Calculation */
  --accent-highlight-glow: rgba(244, 63, 94, 0.25);

  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 20px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 30px -5px rgba(0,0,0,0.5);

  --font-sans: 'Plus Jakarta Sans', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Light Theme Colors */
body.light-theme {
  --bg-app: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-border: rgba(0, 0, 0, 0.08);
  --bg-input: #ffffff;
  --bg-input-focus: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --accent-primary: #0ea5e9;
  --accent-primary-hover: #0284c7;
  --accent-primary-glow: rgba(14, 165, 233, 0.2);
  
  --accent-success: #10b981;
  --accent-success-glow: rgba(16, 185, 129, 0.15);
  
  --accent-highlight: #e11d48;
  --accent-highlight-glow: rgba(225, 29, 72, 0.15);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 15px -3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 25px -5px rgba(0,0,0,0.12);
}

/* Smooth theme transition */
body, .card, .form-select, .form-input, .result-card, .radio-label, .preview-body {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header Styles */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bg-card-border);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--accent-primary);
  filter: drop-shadow(0 0 8px var(--accent-primary-glow));
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #f8fafc, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Main Layout */
.app-main {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

/* Card Component (Glassmorphism) */
.card {
  background-color: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--bg-card-border);
}

.card-header i {
  color: var(--accent-primary);
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Form Styles */
.control-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group.divider-top {
  border-top: 1px dashed var(--bg-card-border);
  padding-top: 20px;
  margin-top: 10px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-label.highlight-label {
  color: var(--accent-primary);
  font-weight: 600;
}

.tooltip-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  cursor: help;
  transition: color 0.2s;
}

.tooltip-icon:hover {
  color: var(--accent-primary);
}

.value-display {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-primary);
  background-color: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 20px;
}

.select-wrapper {
  position: relative;
}

.form-select, .form-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  outline: none;
}

.form-select {
  appearance: none;
  cursor: pointer;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-muted);
  pointer-events: none;
}

.form-select:focus, .form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
  background-color: var(--bg-input-focus);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.input-row.hidden {
  display: none;
}

.input-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-col label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 2px;
}

/* Range input styling */
.range-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

.form-range {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-primary-glow);
  transition: transform 0.1s;
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Radio Group styling */
.radio-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 10px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--border-radius-md);
  transition: all 0.2s;
}

.radio-label:hover {
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--text-primary);
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  position: relative;
  transition: all 0.2s;
}

.radio-label input[type="radio"]:checked + .radio-custom {
  border-color: var(--accent-primary);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  content: '';
  width: 10px;
  height: 10px;
  background-color: var(--accent-primary);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px var(--accent-primary-glow);
}

.radio-label input[type="radio"]:checked ~ span:last-child {
  color: var(--text-primary);
  font-weight: 500;
}

.radio-label:has(input[type="radio"]:checked) {
  border-color: var(--accent-primary);
  background-color: rgba(56, 189, 248, 0.05);
}

/* Highlight Input (Required Data Count) */
.input-with-icon {
  position: relative;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s;
}

.highlight-input {
  padding-left: 44px;
  padding-right: 44px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.highlight-input:focus {
  border-color: var(--accent-primary);
}

.input-with-icon:focus-within .field-icon {
  color: var(--accent-primary);
}

.input-suffix {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
}

/* Button Component */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-text {
  background-color: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
}

.btn-text:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 4px 8px;
}

/* Right Panel: Results & Preview */
.result-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Result Card */
.result-card {
  background-color: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--text-muted);
}

.result-card.primary::before {
  background-color: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-primary-glow);
}

.result-card.primary .result-card-icon {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent-primary);
}

.result-card.highlight::before {
  background-color: var(--accent-highlight);
  box-shadow: 0 0 10px var(--accent-highlight-glow);
}

.result-card.highlight .result-card-icon {
  background-color: rgba(244, 63, 94, 0.1);
  color: var(--accent-highlight);
}

.result-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  background-color: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.result-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}

.result-card-info h3 {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.result-value .unit {
  font-size: 1rem;
  margin-left: 2px;
}

.result-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success-glow);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Result Card Highlight State for Required Count */
#sheetCountCard {
  transition: opacity 0.3s, transform 0.3s;
}

#sheetCountCard.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Preview Card specific */
.preview-card {
  display: flex;
  flex-direction: column;
}

.preview-card .card-header {
  justify-content: space-between;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-legend {
  display: flex;
  gap: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.margin-color {
  background-color: rgba(244, 63, 94, 0.15);
  border: 1px dashed rgba(244, 63, 94, 0.5);
}

.data-color {
  background-color: rgba(56, 189, 248, 0.2);
  border: 1px solid var(--accent-primary);
}

.cut-color {
  border-bottom: 1.5px dashed rgba(255, 255, 255, 0.5);
  height: 0;
  width: 12px;
}

.preview-body {
  flex-grow: 1;
  background-color: rgba(11, 15, 25, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  min-height: 650px;
  position: relative;
}

.canvas-container {
  width: 100%;
  height: 100%;
  max-height: 750px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-container.scrolling {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 16px;
}

#previewCanvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
}

.canvas-container.scrolling #previewCanvas {
  max-width: none;
  max-height: none;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-controls button {
  padding: 4px;
}

.zoom-controls .value-display {
  min-width: 70px;
  text-align: center;
  font-size: 0.82rem;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background-color: rgba(15, 23, 42, 0.4);
  border-top: 1px solid var(--bg-card-border);
}

.footer-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
}

/* Tooltip standard implementation (custom logic if needed) */
[title] {
  position: relative;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
  }
  
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .header-actions {
    width: 100%;
  }
  
  .btn {
    width: 100%;
  }
  
  .preview-legend {
    display: none; /* Hide on small screens to save space */
  }
  
  .preview-body {
    min-height: 350px;
    padding: 12px;
  }
}

/* Print Stylesheet - Optimization for PDF/Printer export */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }
  
  .app-container {
    padding: 0;
    max-width: 100%;
  }
  
  /* Hide UI elements that are not needed on paper */
  .control-panel,
  .header-actions,
  .card-footer,
  #btnResetZoom {
    display: none !important;
  }
  
  .app-main {
    grid-template-columns: 1fr !important;
    gap: 0;
  }
  
  .results-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    margin-bottom: 20px;
    gap: 10px;
  }
  
  .result-card {
    background-color: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    padding: 12px !important;
  }
  
  .result-card::before {
    display: none;
  }
  
  .result-card-icon {
    background-color: #e2e8f0 !important;
    color: #475569 !important;
  }
  
  .result-card-info h3 {
    color: #64748b !important;
  }
  
  .result-value {
    color: #0f172a !important;
    font-size: 1.4rem !important;
  }
  
  .progress-bar-container {
    background-color: #e2e8f0 !important;
  }
  
  .progress-bar {
    background-color: #10b981 !important;
  }
  
  .preview-card {
    border: 1px solid #cbd5e1 !important;
    background-color: #ffffff !important;
    box-shadow: none !important;
  }
  
  .preview-body {
    background-color: #ffffff !important;
    padding: 0 !important;
    min-height: auto !important;
  }
  
  #previewCanvas {
    box-shadow: none !important;
    border: 1px solid #94a3b8 !important;
  }
  
  .preview-legend {
    display: flex !important;
  }
  
  .legend-item {
    color: #475569 !important;
  }
}
