/* 2D Analytical Beam Calculator - Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-app: #f1f3f6;
  --bg-panel: #ffffff;
  --bg-sidebar: #eaedf2;
  --bg-header: #dfe5ec;
  --border-color: #cbd5e1;
  --border-dark: #94a3b8;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent-orange: #d97706;
  --accent-red: #dc2626;
  --accent-green: #16a34a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  background-color: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  font-size: 13.5px;
  user-select: none;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* App Frame */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  min-height: 0;
  background: #ffffff;
  overflow: hidden;
}

/* Window Title Bar */
.window-title-bar {
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  min-height: 40px;
  flex-shrink: 0;
}

.window-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  flex-shrink: 0;
}

.window-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 16px;
}

.menu-btn {
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  transition: all 0.15s;
}
.menu-btn:hover {
  background-color: #cbd5e1;
  color: #0f172a;
}

.user-greeting {
  font-size: 12.5px;
  font-weight: 500;
  color: #64748b;
}

/* Ribbon Controls */
.top-ribbon {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 52px;
  min-height: 52px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.ribbon-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.ribbon-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.radio-pill-group {
  display: flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 7px;
  gap: 3px;
}

.radio-pill {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
}
.radio-pill:hover {
  color: #0f172a;
}
.radio-pill.active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
}
.radio-pill.active .radio-dot {
  background: var(--primary);
}

.btn-kofi {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-kofi:hover {
  background: #fff5f5;
  border-color: #fca5a5;
  color: #b91c1c;
  box-shadow: 0 1px 4px rgba(255, 94, 91, 0.2);
}

.btn-lang {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-lang:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-calc-details {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-calc-details:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* Main Workspace Split */
.main-workspace {
  --sidebar-w: 410px;
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
  height: calc(100vh - 40px - 52px - 32px);
  overflow: hidden;
  position: relative;
}

/* Sidebar Styles */
.sidebar-container {
  width: var(--sidebar-w);
  min-width: 360px;
  max-width: 500px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s, max-width 0.25s, opacity 0.2s;
}

/* Folded / Collapsed Sidebar */
.sidebar-container.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border-right: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Sidebar Toggle Tab Handle (Thumb-friendly for tablets - Centered vertically & enlarged) */
.sidebar-toggle-tab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: var(--sidebar-w);
  z-index: 30;
  width: 28px;
  height: 72px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-left: none;
  border-radius: 0 10px 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.09);
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s, color 0.15s, border-color 0.15s, width 0.15s;
  color: #475569;
}

.sidebar-toggle-tab:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
  width: 32px;
}

.sidebar-toggle-tab .sidebar-toggle-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-container.collapsed + .sidebar-toggle-tab {
  left: 0;
  border-left: 1.5px solid #cbd5e1;
}

.sidebar-container.collapsed + .sidebar-toggle-tab .sidebar-toggle-icon {
  transform: rotate(180deg);
}

/* Scrollable Sidebar Panel with visible, easy-to-use scrollbar */
.sidebar-scroll {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 40px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Prominent Custom Scrollbar for Left Panel */
.sidebar-scroll::-webkit-scrollbar {
  width: 8px;
}
.sidebar-scroll::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 4px;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.poly-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.poly-card-header {
  background: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}
.poly-card-header:hover {
  background: #e2e8f0;
}

.poly-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.poly-card-body {
  padding: 10px 12px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poly-table-container {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  max-height: 260px;
  overflow-y: auto;
}

.poly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.poly-table th {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #f1f5f9;
  padding: 6px 8px;
  font-weight: 700;
  color: #475569;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

.poly-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f8fafc;
  text-align: center;
  vertical-align: middle;
}

.poly-input {
  width: 100%;
  padding: 5px 6px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  text-align: center;
  background: #ffffff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
  appearance: textfield;
}
.poly-input:focus {
  border-color: #3b82f6;
  background-color: #f8fafc;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Hide default browser spinner arrows on number inputs */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.poly-checkbox {
  cursor: pointer;
  accent-color: #2563eb;
  width: 16px;
  height: 16px;
}

.btn-icon-del {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #ef4444;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.15s;
}
.btn-icon-del:hover {
  background-color: #fee2e2;
}

.btn-add {
  width: 100%;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 700;
  background: #f8fafc;
  color: #2563eb;
  border: 1.5px dashed #93c5fd;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
  margin-top: 4px;
  flex-shrink: 0;
}
.btn-add:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

/* Sidebar Footer Badge */
.sidebar-footer {
  padding: 8px 12px;
  background: #e2e8f0;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.poly-badge {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.badge-logo-icon {
  width: 32px;
  height: 32px;
  background: #dbeafe;
  border: 1.5px solid #3b82f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #1e40af;
}

/* Canvas Area */
.canvas-container {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.canvas-toolbar-overlay {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 20;
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.tool-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.tool-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.canvas-main {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Floating Diagram Cursor Tooltip */
.cursor-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.18);
  transform: translate(-50%, -125%);
  white-space: nowrap;
}

/* Bottom Status Bar */
.status-bar {
  background: #f1f5f9;
  border-top: 1px solid var(--border-color);
  padding: 4px 16px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-family: 'JetBrains Mono', monospace;
  color: #334155;
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-val {
  font-weight: 700;
  color: #0f172a;
}

.status-badge-ok {
  background: #dcfce7;
  color: #166534;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}

.status-badge-indeterminate {
  background: #dbeafe;
  color: #1e40af;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  width: 92%;
  max-width: 980px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  font-size: 13.5px;
  line-height: 1.6;
}

.modal-footer {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
}
.btn-secondary:hover {
  background: #f1f5f9;
}

/* Watermark background */
.student-license-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  font-weight: 900;
  transform: rotate(-22deg);
  color: #0f172a;
  z-index: 1;
  user-select: none;
}

/* Canvas Presets Showcase Overlay */
.canvas-presets-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.98);
  backdrop-filter: blur(8px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 32px 24px 60px 24px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.canvas-presets-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.presets-hero-content {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.presets-hero-header {
  text-align: center;
  margin-bottom: 24px;
}

.presets-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.08);
}

.presets-hero-title {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.presets-hero-subtitle {
  color: #64748b;
  font-size: 12.5px;
  max-width: 580px;
  margin: 0 auto;
  line-height: 1.5;
}

.hero-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  width: 100%;
  margin: 0 auto;
}

.preset-hero-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  text-align: left;
  min-height: 125px;
}

.preset-hero-card:hover {
  border-color: #2563eb;
  background: #f8faff;
  box-shadow: 0 10px 24px -4px rgba(37, 99, 235, 0.20);
  transform: translateY(-2.5px);
}

.preset-hero-card .hero-card-title {
  font-weight: 800;
  font-size: 13px;
  color: #0f172a;
}

.preset-hero-card:hover .hero-card-title {
  color: #1d4ed8;
}

.preset-hero-card .hero-card-desc {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.45;
}

/* Floating Action Buttons in Canvas Bottom-Right */
.canvas-bottom-right-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 15;
}

.btn-canvas-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: #ffffff;
  color: #1e40af;
  border: 1.5px solid #93c5fd;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.btn-canvas-action:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(30, 64, 175, 0.18);
}

.btn-canvas-action:active {
  transform: translateY(0);
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Print CSS */
@media print {
  body, html {
    overflow: visible !important;
    height: auto !important;
    background: #ffffff !important;
    font-size: 12pt !important;
  }
  .app-container, .window-title-bar, .top-ribbon, .main-workspace, .status-bar, .canvas-toolbar-overlay, #btnCloseCalcModal, .modal-footer {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: transparent !important;
    padding: 0 !important;
  }
  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }
  .modal-body {
    overflow: visible !important;
    max-height: none !important;
    padding: 0 !important;
  }
  .poly-card, div {
    break-inside: avoid;
  }
}
