/* Upside Down Generator Styles */
.statmat-tool.upside-down {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  color: #1e293b;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.statmat-tool.upside-down * {
  box-sizing: border-box;
}

.statmat-tool.upside-down .ud-header {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  padding: 30px 24px;
  text-align: center;
}

.statmat-tool.upside-down .ud-icon {
  font-size: 38px;
  margin-bottom: 8px;
  display: inline-block;
  transform: rotate(180deg);
}

.statmat-tool.upside-down .ud-header h2 {
  margin: 0 0 8px 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.statmat-tool.upside-down .ud-header p {
  margin: 0;
  font-size: 16px;
  color: #bfdbfe;
}

.statmat-tool.upside-down .ud-container {
  padding: 0;
  background-color: #f8fafc;
}

/* Tabs */
.statmat-tool.upside-down .ud-tabs {
  display: flex;
  background-color: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.statmat-tool.upside-down .tab-btn {
  flex: 1;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  color: #64748b;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.statmat-tool.upside-down .tab-btn:hover {
  color: #3b82f6;
  background-color: #fff;
}

.statmat-tool.upside-down .tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background-color: #fff;
}

.statmat-tool.upside-down .tab-content {
  display: none;
  padding: 30px;
}

.statmat-tool.upside-down .tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Inputs */
.statmat-tool.upside-down .input-section {
  background-color: #fff;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.statmat-tool.upside-down label {
  display: block;
  font-weight: 600;
  color: #475569;
  margin-bottom: 10px;
  font-size: 14px;
}

.statmat-tool.upside-down textarea,
.statmat-tool.upside-down .full-input,
.statmat-tool.upside-down select {
  width: 100%;
  padding: 14px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  font-size: 18px;
  color: #1e293b;
  transition: all 0.2s;
  font-family: inherit;
}

.statmat-tool.upside-down textarea {
  resize: vertical;
}

.statmat-tool.upside-down textarea:focus,
.statmat-tool.upside-down .full-input:focus,
.statmat-tool.upside-down select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.statmat-tool.upside-down .checkbox-group {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.statmat-tool.upside-down .inline-label {
  display: inline;
  margin: 0;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
}

.statmat-tool.upside-down input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.statmat-tool.upside-down .input-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.statmat-tool.upside-down .row-group {
  display: flex;
  gap: 16px;
}

.statmat-tool.upside-down .control-group {
  flex: 1;
}

.statmat-tool.upside-down .mt-3 { margin-top: 16px; }
.statmat-tool.upside-down .mt-4 { margin-top: 24px; }
.statmat-tool.upside-down .w-100 { width: 100%; justify-content: center; }

.statmat-tool.upside-down input[type="color"] {
  width: 100%;
  height: 48px;
  padding: 2px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
}

/* Buttons */
.statmat-tool.upside-down .btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.statmat-tool.upside-down .btn-secondary {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.statmat-tool.upside-down .btn-secondary:hover {
  background-color: #e2e8f0;
}

.statmat-tool.upside-down .btn-primary {
  background-color: #2563eb;
  color: white;
}

.statmat-tool.upside-down .btn-primary:hover {
  background-color: #1d4ed8;
}

/* Results */
.statmat-tool.upside-down .results-section {
  background-color: #fff;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.statmat-tool.upside-down .results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.statmat-tool.upside-down .results-header h3 {
  margin: 0;
  font-size: 18px;
  color: #1e293b;
}

.statmat-tool.upside-down .result-box {
  padding: 24px;
  font-size: 24px;
  color: #0f172a;
  background-color: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  text-align: center;
  word-break: break-all;
  white-space: pre-wrap;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Canvas */
.statmat-tool.upside-down .tab-desc {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 15px;
  color: #64748b;
  line-height: 1.5;
}

.statmat-tool.upside-down .canvas-preview {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.statmat-tool.upside-down canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  background-color: #fff;
  background-image: linear-gradient(45deg, #f1f5f9 25%, transparent 25%), 
                    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #f1f5f9 75%), 
                    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Toast */
.statmat-tool.upside-down .toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: #1e293b;
  color: white;
  padding: 12px 28px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
  z-index: 9999;
}

.statmat-tool.upside-down .toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Global override for mobile scrolling on long results */
.statmat-tool [class*="result"], 
.statmat-tool [class*="output"],
.statmat-tool [class*="preview"],
.statmat-tool [class*="display"] {
  overflow-x: auto;
  max-width: 100%;
}

/* Global safeguard: ensure main wrapper never exceeds mobile viewport */
.statmat-tool {
  width: 100% !important;
  box-sizing: border-box;
}
