﻿/* ===== Root Variables ===== */
:root {
  --sidebar-width: 264px;
  --sidebar-bg: #233036;
  --sidebar-bg-deep: #1f2a30;
  --sidebar-text: #f4f7f8;
  --sidebar-muted: #8d9aa2;
  --sidebar-active: #26343a;
  --sidebar-hover: #2a3940;
  --main-bg: #f8fafc;
  --header-bg: #ffffff;
  --card-bg: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --footer-bg: #0f172a;
  --accent-color: #2997ff;
  --success-color: #55c69b;
  --danger-color: #ff5d72;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* ===== Global Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--main-bg);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ===== App Container ===== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar Styles ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-muted);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  box-shadow: inset 2px 0 0 var(--accent-color), 8px 0 24px rgba(18, 27, 32, 0.18);
  display: flex;
  flex-direction: column;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* Sidebar Header */
.sidebar-header {
  padding: 24px 26px 10px;
  border-bottom: 0;
}

.logo-container {
  background: #fff;
  border-radius: 8px;
  display: block;
  margin-inline: auto;
  max-width: 100%;
  width: fit-content;
}

.logo-container img {
  border-radius: inherit;
  display: block;
  height: auto;
  max-width: 100%;
}

.logo-container:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 4px;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 0 22px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 30px;
}

.nav-section-title {
  padding: 0 26px;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--sidebar-muted);
  margin-bottom: 18px;
}

.nav-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.nav-item {
  margin: 0;
  padding: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 46px;
  padding: 11px 32px;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
  cursor: pointer;
  font: inherit;
  font-size: 16px;
  text-align: left;
}

.nav-link:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background-color: var(--sidebar-active);
  color: #fff;
}

.nav-link i {
  flex: 0 0 18px;
  font-size: 16px;
  width: 20px;
  color: currentColor;
  opacity: 0.85;
  text-align: center;
}

.nav-link span {
  min-width: 0;
}

.nav-dropdown-toggle .dropdown-icon,
.nav-caret {
  margin-left: auto;
  flex: 0 0 auto;
  width: auto;
  font-size: 12px;
  color: currentColor;
  opacity: 0.9;
  transition: transform 0.2s ease;
}

.has-submenu.open .dropdown-icon {
  transform: rotate(0deg);
}

.has-submenu:not(.open) .dropdown-icon {
  transform: rotate(-90deg);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--success-color);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.submenu {
  display: none;
  list-style: none;
  margin: 2px 0 0;
  padding: 0 32px 12px 65px;
  background: var(--sidebar-bg-deep);
}

.has-submenu.open .submenu {
  display: block;
}

.submenu-link {
  display: flex;
  align-items: center;
  min-height: 37px;
  gap: 10px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}

.submenu-link:hover,
.submenu-link.active {
  color: #fff;
}

.submenu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 20px;
  margin-left: auto;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--danger-color);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 10px;
  justify-content: center;
}

.sidebar-footer-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  font-size: 18px;
}

.sidebar-footer-link:hover {
  background-color: rgba(59, 130, 246, 0.3);
  color: #fff;
  transform: translateY(-2px);
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  box-shadow: inset 2px 0 0 var(--accent-color), 8px 0 24px rgba(18, 27, 32, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s ease;
}

body.sidebar-hidden .sidebar {
  transform: translateX(-100%);
}

body.sidebar-hidden .main-content,
body.sidebar-hidden .app-footer {
  margin-left: 0;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ===== Top Header ===== */
.top-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.sidebar-toggle {
  display: flex;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  background-color: var(--main-bg);
  color: var(--accent-color);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--main-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  width: 250px;
  transition: all 0.3s ease;
}

.search-box:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box i {
  color: var(--text-secondary);
  font-size: 16px;
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.search-box input::placeholder {
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.header-btn:hover {
  background-color: var(--main-bg);
  color: var(--accent-color);
}

/* ===== Content Wrapper ===== */
.content-wrapper {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ===== Hero Section ===== */
.hero-section {
  background: linear-gradient(135deg, var(--accent-color) 0%, #1e40af 100%);
  border-radius: 12px;
  isolation: isolate;
  padding: 40px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-lg);
}

.hero-logo {
  /* Screen blending lets the gradient show through the logo's white source background. */
  filter: grayscale(1) invert(1) brightness(3);
  height: auto;
  max-width: 100%;
  mix-blend-mode: screen;
  width: clamp(144px, 16vw, 210px);
}

.hero-section h1 {
  color: white;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero-section .lead {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.1rem;
  margin-bottom: 24px;
}

.hero-section .btn-light {
  background-color: white;
  border-color: white;
  color: var(--accent-color);
  font-weight: 600;
  padding: 12px 28px;
  transition: all 0.3s ease;
}

.hero-section .btn-light:hover {
  background-color: rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

/* ===== Cards Grid ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-color);
}

.card-image {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, #f0f4f8 0%, #e8eef5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-image--product {
  background: #f5f6f5;
}

.card-image--product img {
  object-fit: contain;
}

.card-image--square {
  background: #fff;
}

.card-image--square img {
  height: auto;
  width: min(100%, 350px);
}

.card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.card-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 16px;
}

.card-footer {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.card .btn-sm {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
}

/* ===== Vacuum Cup Customizer ===== */
.cup-customizer {
  --cup-ink: #16243c;
  --cup-muted: #52627a;
  --cup-line: #dbe3ee;
  background: #fff;
  border: 1px solid var(--cup-line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  color: var(--cup-ink);
  overflow: hidden;
}

.cup-customizer-header {
  padding: 24px clamp(16px, 3vw, 32px);
}

.cup-customizer-header h2 {
  font-size: clamp(1.45rem, 2.7vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: 0 0 6px;
}

.cup-customizer-header p,
.cup-model-details p {
  color: var(--cup-muted);
  margin: 0;
}

.cup-customizer-layout {
  border-top: 1px solid var(--cup-line);
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr);
}

.cup-preview {
  background: radial-gradient(ellipse at 50% 46%, #354d78, #192941 65%, #142239);
  color: #e0eafa;
  min-height: 410px;
  overflow: hidden;
  position: relative;
}

.cup-preview::before {
  background-image: linear-gradient(#9bb8ea20 1px, transparent 1px),
    linear-gradient(90deg, #9bb8ea20 1px, transparent 1px);
  background-size: 34px 34px;
  content: "";
  inset: 0;
  mask-image: radial-gradient(ellipse, #000, transparent 74%);
  pointer-events: none;
  position: absolute;
}

.cup-preview canvas {
  cursor: grab;
  height: 100%;
  inset: 0;
  position: absolute;
  touch-action: none;
  width: 100%;
}

.cup-preview canvas:active {
  cursor: grabbing;
}

.cup-preview-status {
  left: 50%;
  margin: 0;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(85%, 300px);
}

.cup-preview-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
  margin: 12px;
  pointer-events: none;
  position: relative;
}

.cup-view-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cup-view-controls button {
  background: #142239;
  border: 1px solid #637696;
  border-radius: 8px;
  color: #e0eafa;
  font-size: 0.8rem;
  min-height: 36px;
  min-width: 36px;
  padding: 4px 8px;
  pointer-events: auto;
}

.cup-view-controls button[aria-pressed="true"] {
  background: #d5ff76;
  border-color: #d5ff76;
  color: #182711;
  font-weight: 700;
}

.cup-preview button:focus-visible,
.cup-preview canvas:focus-visible {
  outline: 2px solid #d5ff76;
  outline-offset: 2px;
}

.cup-preview canvas:focus-visible {
  outline-offset: -4px;
}

.cup-preview-help {
  bottom: 0;
  color: #c6d5ed;
  font-size: 0.8rem;
  margin: 10px 14px;
  pointer-events: none;
  position: absolute;
}

.cup-options {
  padding: clamp(16px, 2.5vw, 28px);
}

.cup-model-details {
  border-bottom: 1px solid var(--cup-line);
  margin-bottom: 18px;
  padding-bottom: 16px;
}

.cup-model-details h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0 0 4px;
}

.cup-model-details p {
  font-size: 0.85rem;
}

.cup-options fieldset {
  margin-bottom: 18px;
}

.cup-options legend {
  font-size: 0.85rem;
  font-weight: 750;
}

.cup-part-options,
.cup-color-options {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cup-options label {
  align-items: center;
  border: 1px solid var(--cup-line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  font-size: 0.83rem;
  gap: 6px;
  min-height: 40px;
  padding: 5px 8px;
}

.cup-options label:has(input:checked) {
  background: #eef5ff;
  border-color: #2468c5;
  color: #144c9b;
  font-weight: 700;
}

.cup-options label:has(input:focus-visible),
.cup-reset-colors:focus-visible {
  outline: 2px solid #2468c5;
  outline-offset: 2px;
}

.cup-options input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.cup-swatch {
  background: var(--cup-swatch);
  border: 1px solid #0002;
  border-radius: 50%;
  flex: 0 0 16px;
  height: 16px;
}

.cup-reset-colors {
  background: transparent;
  border: 1px solid var(--cup-line);
  border-radius: 8px;
  color: var(--cup-ink);
  font-size: 0.83rem;
  font-weight: 700;
  min-height: 40px;
  padding: 6px 12px;
}

.cup-options label:hover,
.cup-reset-colors:hover {
  border-color: #2468c5;
}

.cup-customizer :disabled {
  cursor: default;
  opacity: 0.55;
}

@media (max-width: 1020px) {
  .cup-customizer-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .cup-preview {
    min-height: clamp(285px, 58vw, 410px);
  }
}

/* ===== CAD Viewer ===== */
.cad-viewer-section {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.cad-viewer-toolbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 20px 22px;
}

.cad-viewer-toolbar h2 {
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0;
}

.cad-viewer-status {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 650;
  margin-top: 5px;
}

.cad-viewer-controls {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 420px) auto;
}

.cad-viewer {
  background:
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    #f6f8fb;
  background-size: 28px 28px;
  border-top: 1px solid rgba(226, 232, 240, 0.95);
  height: min(680px, calc(100vh - 160px));
  min-height: 480px;
  position: relative;
}

.cad-viewer canvas {
  cursor: grab;
  display: block;
  height: 100%;
  width: 100%;
}

.cad-viewer canvas:active {
  cursor: grabbing;
}

/* ===== App Footer ===== */
.app-footer {
  background: var(--footer-bg);
  color: rgba(255, 255, 255, 0.7);
  padding: 24px;
  text-align: center;
  margin-left: var(--sidebar-width);
  border-top: 1px solid var(--border-color);
}

.footer-content {
  font-size: 14px;
}

.footer-content a {
  color: var(--accent-color);
  text-decoration: none;
  transition: all 0.3s ease;
}

.footer-content a:hover {
  text-decoration: underline;
  color: #60a5fa;
}

/* ===== Button Styles ===== */
.btn-primary {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
  font-weight: 600;
  transition: all 0.3s ease;
  border-radius: 8px;
}

.btn-primary:hover {
  background-color: #2563eb;
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.btn-light {
  background-color: white;
  border-color: white;
  color: var(--text-primary);
  font-weight: 600;
  border-radius: 8px;
}

.btn-light:hover {
  background-color: var(--main-bg);
  transform: translateY(-2px);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.active,
  body.sidebar-hidden .sidebar {
    width: var(--sidebar-width);
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .app-footer {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .search-box {
    display: none;
  }

  .top-header {
    justify-content: space-between;
  }

  .content-wrapper {
    padding: 16px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hero-section {
    padding: 24px;
  }

  .hero-section h1 {
    font-size: 1.8rem;
  }

  .hero-section .lead {
    font-size: 1rem;
  }

  .cad-viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .cad-viewer-controls {
    grid-template-columns: 1fr;
  }

  .cad-viewer {
    height: 520px;
    min-height: 420px;
  }
}

@media (max-width: 480px) {
  .header-right {
    gap: 8px;
  }

  .hero-section {
    padding: 16px;
  }

  .hero-section h1 {
    font-size: 1.5rem;
  }

  .card {
    border-radius: 8px;
  }

  .top-header {
    padding: 12px 16px;
  }

  .content-wrapper {
    padding: 12px;
  }
}
