/* ==========================================================================
   A4 Sticker Sheet Creator - Modern Premium Light Theme
   Full Responsiveness: Mobile (Phones) • Tablets • Laptops • Desktops
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Theme Variables & Design Tokens (Light Theme)
   -------------------------------------------------------------------------- */
:root {
  /* Surface & Background Colors */
  --bg-app: #f8fafc;
  --bg-header: rgba(255, 255, 255, 0.92);
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;
  --bg-input-focus: #ffffff;
  --bg-preview: #e2e8f0;

  /* Text & Content */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Accent & State Colors */
  --accent-color: #0f2446; /* Deep Brand Navy */
  --accent-hover: #16325c;
  --accent-light: rgba(15, 36, 70, 0.08);
  --accent-glow: rgba(15, 36, 70, 0.25);
  --accent-gradient: linear-gradient(135deg, #0f2446 0%, #1e3a68 100%);
  
  --success-color: #059669;
  --success-hover: #047857;
  --success-light: rgba(5, 150, 105, 0.1);
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);

  --danger-color: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.1);

  --warning-color: #d97706;

  /* Borders & Glassmorphism */
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --border-light: #f1f5f9;
  --glass-bg: rgba(255, 255, 255, 0.88);
  --glass-blur: blur(14px);

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-sheet: 0 15px 35px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);

  /* Scale default: 1mm = 3px on screen for high resolution preview */
  --mm-scale: 3.0px;

  /* Sticker default parameters in mm (updated via JS dynamically) */
  --diameter: 40;
  --width: 40;
  --height: 40;
  --bleed: 2.5;
  --margin-top: 8.15;
  --margin-left: 10;
  --gap-x: 10;
  --gap-y: 8.14;
  
  /* Calibration offsets in mm */
  --calib-x: 0;
  --calib-y: 0;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   2. Global Reset & Base Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 10% 10%, rgba(15, 36, 70, 0.03) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(15, 36, 70, 0.03) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Language specific font adjustments */
html[dir="rtl"] {
  font-family: 'Tajawal', sans-serif;
}
html[dir="ltr"] {
  font-family: 'Tajawal', sans-serif;
}

/* Custom Modern Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* --------------------------------------------------------------------------
   2.5 Ultra-Premium Cinematic Intro Experience (Light Mode)
   -------------------------------------------------------------------------- */
.intro-cinematic-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(248, 250, 252, 0.98);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.7s ease;
}

.intro-cinematic-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.06);
  pointer-events: none;
}

/* Ambient Canvas Background with Soft Light Aurora */
.intro-bg-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.intro-grid-pattern {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: 
    linear-gradient(to right, rgba(15, 36, 70, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 36, 70, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  transform: perspective(600px) rotateX(45deg);
  animation: gridDrift 20s linear infinite;
}

@keyframes gridDrift {
  0% { transform: perspective(600px) rotateX(45deg) translateY(0); }
  100% { transform: perspective(600px) rotateX(45deg) translateY(36px); }
}

.intro-aurora-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.6;
}

.intro-aurora-glow.aurora-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(15, 36, 70, 0.09) 0%, rgba(15, 36, 70, 0) 70%);
  top: -150px;
  right: -100px;
  animation: auroraFloat1 8s ease-in-out infinite alternate;
}

.intro-aurora-glow.aurora-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0) 70%);
  bottom: -200px;
  left: -150px;
  animation: auroraFloat2 10s ease-in-out infinite alternate;
}

@keyframes auroraFloat1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-60px, 60px) scale(1.15); }
}

@keyframes auroraFloat2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(70px, -50px) scale(1.2); }
}

/* Skip Button (Light Mode) */
.intro-skip-btn {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1.1rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--accent-color);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all var(--transition-fast);
}

.intro-skip-btn:hover {
  background: #f8fafc;
  border-color: var(--accent-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 36, 70, 0.1);
}

html[dir="rtl"] .intro-skip-btn {
  left: 1.5rem;
  right: auto;
}

/* Main Cinematic Card (Light Mode) */
.intro-cinematic-card {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 480px;
  width: 90%;
  padding: 2.5rem 2rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 28px;
  box-shadow: 
    0 20px 45px rgba(15, 36, 70, 0.09),
    0 1px 3px rgba(0, 0, 0, 0.04);
  animation: cardCinemaReveal 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardCinemaReveal {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(24px);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

/* 3D Orbital Logo Stage */
.intro-orbital-stage {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.intro-orbital-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.intro-orbital-ring circle {
  fill: none;
  stroke-width: 2;
  transform-origin: center;
}

.intro-orbital-ring.ring-outer circle {
  stroke: rgba(15, 36, 70, 0.25);
  stroke-dasharray: 12 18;
  animation: rotateOrbitalRight 12s linear infinite;
}

.intro-orbital-ring.ring-inner circle {
  stroke: rgba(37, 99, 235, 0.35);
  stroke-dasharray: 8 14;
  animation: rotateOrbitalLeft 9s linear infinite;
}

@keyframes rotateOrbitalRight {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotateOrbitalLeft {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

.intro-logo-shine {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: radial-gradient(circle, rgba(15, 36, 70, 0.08) 0%, transparent 70%);
  animation: pulseLogoGlow 2.5s ease-in-out infinite alternate;
}

@keyframes pulseLogoGlow {
  0% { transform: scale(0.9); opacity: 0.4; }
  100% { transform: scale(1.2); opacity: 0.8; }
}

.intro-hero-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 20px;
  position: relative;
  z-index: 3;
  filter: drop-shadow(0 8px 20px rgba(15, 36, 70, 0.12));
  animation: heroLogoIntro 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes heroLogoIntro {
  from {
    transform: scale(0.4) rotate(-10deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* Typography Reveal */
.intro-brand-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.75rem;
}

.intro-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 4px 14px;
  background: var(--accent-light);
  border: 1px solid rgba(15, 36, 70, 0.15);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent-color);
  margin-bottom: 0.75rem;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow: 0 0 6px rgba(15, 36, 70, 0.5);
  animation: blinkDot 1.2s infinite ease-in-out;
}

@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.intro-main-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  margin-bottom: 0.65rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.brand-text-vivo {
  color: var(--accent-color);
}

.brand-text-labels {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.5;
  min-height: 1.5rem;
  transition: opacity 0.3s ease;
}

/* High-Tech Progress Meter (Light Mode) */
.intro-tech-meter {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.intro-meter-track {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
}

.intro-meter-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 0.08s linear;
}

.intro-meter-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 2px;
}

.meter-label {
  letter-spacing: 0.1em;
}

.meter-percent {
  color: var(--accent-color);
  font-weight: 700;
}
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-header);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
  min-height: 64px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-logo-img {
  height: 40px;
  width: auto;
  max-width: 48px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  transition: transform var(--transition-fast);
}

.header-logo-img:hover {
  transform: scale(1.05);
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-titles h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-main);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Mobile Segmented View Mode Switcher */
.mobile-view-switcher {
  display: none;
  background: #e2e8f0;
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 3px;
}

.mobile-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.mobile-view-btn i {
  font-size: 0.85rem;
}

.mobile-view-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.badge-count {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-header-print {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  background: var(--success-gradient);
  color: white;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
  transition: all var(--transition-normal);
}

.btn-header-print:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-header-print:active {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   4. App Container & Layout
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 64px);
  position: relative;
}

/* --------------------------------------------------------------------------
   5. Sidebar Styling
   -------------------------------------------------------------------------- */
.sidebar {
  width: 440px;
  max-width: 440px;
  min-width: 360px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color); /* For RTL */
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.02);
  transition: transform var(--transition-normal);
}

html[dir="ltr"] .sidebar {
  border-left: none;
  border-right: 1px solid var(--border-color);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.02);
}

/* Sidebar Tab Navigation */
.sidebar-tabs {
  display: flex;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 0.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-align: center;
}

.tab-btn i {
  font-size: 1.05rem;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
}

.tab-btn.active {
  color: #ffffff;
  background: var(--accent-gradient);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.2s ease-out;
}

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

/* --------------------------------------------------------------------------
   6. Card Panel Styling
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.card h2 {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.65rem;
  color: var(--text-main);
}

.card h2 i {
  color: var(--accent-color);
  font-size: 0.95rem;
}

.section-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.section-subheading {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --------------------------------------------------------------------------
   7. Form Controls & Inputs
   -------------------------------------------------------------------------- */
.control-group {
  margin-bottom: 0.9rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.control-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.val-display {
  color: var(--accent-color);
  font-weight: 700;
  font-size: 0.82rem;
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.range-input {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--accent-glow);
  transition: transform var(--transition-fast);
  border: 2px solid #ffffff;
}

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

.range-input::-webkit-slider-thumb:active {
  transform: scale(0.95);
}

.text-input, .select-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition-fast);
}

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

.select-input {
  cursor: pointer;
}

.select-input option {
  background: #ffffff;
  color: var(--text-main);
}

.control-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.control-group-border {
  border: 1px solid var(--border-color);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.9rem;
  background: #f8fafc;
}

/* Color Pickers */
.color-picker-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input {
  width: 44px;
  height: 38px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}

.color-input-small {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 2px;
}

.color-hex {
  text-transform: uppercase;
  font-family: monospace;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

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

.btn-secondary {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.btn-success {
  background: var(--success-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

.btn-lang {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
}

.btn-lang:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: #ffffff;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-group input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   8. Dropzone Section
   -------------------------------------------------------------------------- */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: #f8fafc;
  position: relative;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-color);
  background: var(--accent-light);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  font-size: 2.2rem;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.dropzone:hover .dropzone-icon {
  transform: translateY(-4px);
  color: var(--accent-color);
}

.dropzone-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* --------------------------------------------------------------------------
   9. Visual Sticker Editor Workspace
   -------------------------------------------------------------------------- */
.workspace-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f8fafc;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  position: relative;
  min-height: 280px;
}

.sticker-workspace {
  position: relative;
  width: 240px;
  height: 240px;
  background: #e2e8f0;
  border-radius: 50%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
}

.workspace-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background-color: #ffffff;
  cursor: grab;
  touch-action: none;
}

.workspace-bg:active {
  cursor: grabbing;
}

.workspace-img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  pointer-events: none;
  display: none;
}

.workspace-text-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sticker-svg-text {
  width: 100%;
  height: 100%;
}

.sticker-svg-text text {
  font-weight: bold;
}

.workspace-guide {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
}

.safe-guide {
  width: 80%;
  height: 80%;
  border: 2px dashed var(--success-color);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.06);
}

.bleed-guide {
  width: 100%;
  height: 100%;
  border: 1.5px solid var(--danger-color);
}

.workspace-info-badge {
  position: absolute;
  bottom: -12px;
  background: var(--success-gradient);
  color: white;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  z-index: 12;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.3);
}

/* --------------------------------------------------------------------------
   10. Segmented Drag Mode Selector & Link Toggles
   -------------------------------------------------------------------------- */
.drag-mode-selector {
  display: flex;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 0.5rem;
  padding: 3px;
  gap: 3px;
}

.drag-mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all var(--transition-fast);
  font-family: inherit;
  border-radius: var(--radius-sm);
}

.drag-mode-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-main);
}

.drag-mode-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 6px var(--accent-glow);
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.label-with-action label {
  margin-bottom: 0 !important;
}

.btn-link-toggle {
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--accent-color);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-link-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent-color);
}

.btn-link-toggle.unlinked {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-muted);
}

.individual-gaps-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: #f8fafc;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  max-height: 180px;
  overflow-y: auto;
}

.individual-gap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.individual-gap-row span {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.individual-gap-row input {
  width: 70px;
  padding: 2px 6px;
  font-size: 0.8rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   11. Preview Area & A4 Sheet Canvas
   -------------------------------------------------------------------------- */
.preview-area {
  flex: 1;
  background-color: var(--bg-preview);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem;
  overflow-y: auto;
  position: relative;
}

.preview-header {
  text-align: center;
  margin-bottom: 1.25rem;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.preview-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Preview Sheet Zoom Toolbar */
.preview-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  margin-top: 0.85rem;
  box-shadow: var(--shadow-md);
}

.sheet-zoom-input {
  font-size: 0.82rem;
  font-weight: 700;
  width: 52px;
  text-align: center;
  color: var(--accent-color);
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 4px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.sheet-zoom-input:focus {
  border-color: var(--accent-color);
  background: #ffffff;
}

.preview-zoom-controls .btn {
  border-radius: 50%;
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
}

/* Scroll Container for Sheet */
.sheet-scroll-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  padding-bottom: 3rem;
  overflow-x: auto;
}

/* Rulers Wrapper */
.page-ruler-wrapper {
  position: relative;
  margin-top: 24px; /* Space for horizontal ruler */
  margin-left: 24px; /* Space for vertical ruler */
  transition: transform var(--transition-fast);
}

.ruler-horizontal {
  position: absolute;
  top: -22px;
  left: 0;
  width: calc(210 * var(--mm-scale));
  height: 22px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  user-select: none;
  cursor: row-resize;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.ruler-vertical {
  position: absolute;
  top: 0;
  left: -22px;
  width: 22px;
  height: calc(297 * var(--mm-scale));
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  user-select: none;
  cursor: col-resize;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.tick {
  position: absolute;
  background-color: #94a3b8;
}

.ruler-horizontal .tick {
  width: 1px;
  bottom: 0;
}
.ruler-horizontal .tick-minor { height: 4px; }
.ruler-horizontal .tick-medium { height: 8px; }
.ruler-horizontal .tick-major { height: 13px; background-color: var(--accent-color); }

.ruler-horizontal .tick-label {
  position: absolute;
  font-size: 8px;
  color: #64748b;
  bottom: 10px;
  transform: translateX(-50%);
  font-family: monospace;
  pointer-events: none;
}

.ruler-vertical .tick {
  height: 1px;
  right: 0;
}
.ruler-vertical .tick-minor { width: 4px; }
.ruler-vertical .tick-medium { width: 8px; }
.ruler-vertical .tick-major { width: 13px; background-color: var(--accent-color); }

.ruler-vertical .tick-label {
  position: absolute;
  font-size: 8px;
  color: #64748b;
  right: 11px;
  transform: translateY(-50%);
  font-family: monospace;
  pointer-events: none;
}

/* User pulled custom guide lines */
.page-guides-container {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(210 * var(--mm-scale));
  height: calc(297 * var(--mm-scale));
  pointer-events: none;
  z-index: 100;
}

.user-guide-line {
  position: absolute;
  background-color: #0f2446;
  pointer-events: auto;
  z-index: 101;
}

.user-guide-line.horizontal {
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-1px);
  cursor: row-resize;
}

.user-guide-line.vertical {
  top: 0;
  height: 100%;
  width: 2px;
  transform: translateX(-1px);
  cursor: col-resize;
}

.user-guide-line:hover {
  background-color: #dc2626 !important;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.7);
}

.guide-tooltip {
  position: fixed;
  background: #0f172a;
  color: white;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  font-family: monospace;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   12. The A4 Page & Printed Sticker Cells
   -------------------------------------------------------------------------- */
.a4-page {
  position: relative;
  width: calc(210 * var(--mm-scale));
  height: calc(297 * var(--mm-scale));
  background-color: #ffffff;
  box-shadow: var(--shadow-sheet);
  border-radius: 4px;
  overflow: hidden;
  transition: width 0.15s ease, height 0.15s ease;
  touch-action: pan-y;
}

.sticker-cell {
  position: absolute;
  width: calc(var(--width) * var(--mm-scale));
  height: calc(var(--height) * var(--mm-scale));
  left: calc(var(--cell-left) * var(--mm-scale));
  top: calc(var(--cell-top) * var(--mm-scale));
  border-radius: 50%;
  overflow: hidden;
  background-color: #ffffff;
  pointer-events: auto !important;
  cursor: grab;
  touch-action: none;
}

.sticker-cell:active {
  cursor: grabbing;
}

.sticker-cell-content {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background-color: #ffffff;
}

.sticker-cell-img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
}

/* Guide outlines rendered on A4 sheet for screen layout verification */
.sticker-cell-guide {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

.cell-cut-guide {
  width: calc((var(--width) - 2 * var(--bleed)) * var(--mm-scale));
  height: calc((var(--height) - 2 * var(--bleed)) * var(--mm-scale));
  left: calc((var(--cell-left) + var(--bleed)) * var(--mm-scale));
  top: calc((var(--cell-top) + var(--bleed)) * var(--mm-scale));
  border: 0.8px dashed var(--success-color);
  opacity: 0.75;
}

.cell-bleed-guide {
  width: calc(var(--width) * var(--mm-scale));
  height: calc(var(--height) * var(--mm-scale));
  left: calc(var(--cell-left) * var(--mm-scale));
  top: calc(var(--cell-top) * var(--mm-scale));
  border: 0.5px solid var(--danger-color);
  opacity: 0.45;
}

.hide-screen-guides .sticker-cell-guide {
  display: none !important;
}

.print-cut-outline {
  border: 0.25px solid rgba(0, 0, 0, 0.15) !important;
}

/* Rectangle Shape Styles */
.shape-rectangle,
.shape-rectangle .sticker-cell,
.shape-rectangle .sticker-cell-content,
.shape-rectangle .sticker-cell-guide,
.shape-rectangle .workspace-bg,
.shape-rectangle .workspace-guide {
  border-radius: var(--radius-sm) !important;
}

/* --------------------------------------------------------------------------
   13. Mobile Bottom Floating Action Bar
   -------------------------------------------------------------------------- */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-color);
  padding: 0.65rem 1rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  z-index: 999;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

.mobile-bar-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.mobile-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --------------------------------------------------------------------------
   14. Responsive Breakpoints & Device Adaptations
   -------------------------------------------------------------------------- */

/* Laptops and Small Desktops (1024px to 1280px) */
@media (max-width: 1280px) {
  .sidebar {
    width: 380px;
    max-width: 380px;
    padding: 1rem;
  }
}

/* Tablets and Mobile Landscape / Medium Screens (<= 992px) */
@media (max-width: 992px) {
  .header-bar {
    flex-direction: column;
    padding: 0.65rem 0.9rem;
    gap: 0.5rem;
    min-height: auto;
  }

  .header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .header-subtitle {
    display: none;
  }

  .header-logo {
    gap: 0.6rem;
  }

  .header-logo-img {
    height: 34px;
    max-width: 40px;
  }

  .header-titles h1 {
    font-size: 1rem;
  }

  /* Full-width segmented mobile switcher */
  .mobile-view-switcher {
    display: flex;
    width: 100%;
    background: #e2e8f0;
    border: 1px solid var(--border-color);
    padding: 3px;
    border-radius: var(--radius-md);
    gap: 4px;
  }

  .mobile-view-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
  }

  .header-actions .btn-header-print {
    display: none; /* Accessible via mobile bottom bar or tab */
  }

  .btn-lang {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
  }

  .app-container {
    flex-direction: column;
    height: calc(100vh - 105px);
    overflow: hidden;
    position: relative;
  }

  /* Responsive View Switching: Editor View vs Preview View */
  .app-container.view-mode-editor .sidebar {
    display: flex;
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-left: none;
    border-right: none;
    padding: 0.85rem;
    padding-bottom: 5.5rem; /* Space for bottom bar */
  }

  .app-container.view-mode-editor .preview-area {
    display: none;
  }

  .app-container.view-mode-preview .sidebar {
    display: none;
  }

  .app-container.view-mode-preview .preview-area {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 0.75rem;
    padding-bottom: 5.5rem;
  }

  /* Show mobile floating bottom bar */
  .mobile-bottom-bar {
    display: flex;
  }

  .preview-zoom-controls {
    margin-top: 0.5rem;
  }

  .preview-header {
    margin-bottom: 0.75rem;
  }
}

/* Smartphones & Small Screens (<= 576px) */
@media (max-width: 576px) {
  .header-bar {
    padding: 0.55rem 0.75rem;
    gap: 0.45rem;
  }

  .header-titles h1 {
    font-size: 0.92rem;
  }

  .header-logo-img {
    height: 30px;
    max-width: 36px;
  }

  .mobile-view-btn {
    padding: 0.45rem 0.35rem;
    font-size: 0.76rem;
    gap: 0.3rem;
  }

  .btn-lang {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .card {
    padding: 0.9rem;
    border-radius: var(--radius-md);
  }

  .card h2 {
    font-size: 0.95rem;
  }

  .workspace-wrapper {
    min-height: 230px;
    padding: 0.85rem;
  }

  .sticker-workspace {
    width: 190px;
    height: 190px;
  }

  .control-group-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .page-ruler-wrapper {
    margin-top: 20px;
    margin-left: 20px;
  }

  .ruler-horizontal {
    top: -18px;
    height: 18px;
  }

  .ruler-vertical {
    left: -18px;
    width: 18px;
  }
}

/* --------------------------------------------------------------------------
   15. Millimeter-Accurate Physical Print Stylesheet
   -------------------------------------------------------------------------- */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  
  html, body {
    width: 210mm !important;
    height: 297mm !important;
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .no-print,
  .mobile-bottom-bar,
  .header-bar,
  .sidebar,
  .preview-header,
  .page-guides-container,
  .ruler-horizontal,
  .ruler-vertical,
  .guide-tooltip {
    display: none !important;
  }

  .app-container {
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
  }

  .page-ruler-wrapper {
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  .preview-area {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    display: block !important;
    overflow: visible !important;
  }

  .sheet-scroll-container {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    overflow: visible !important;
  }

  /* Force exact A4 dimensions in physical millimeters */
  .a4-page {
    position: absolute !important;
    top: calc(var(--calib-y) * 1mm) !important;
    left: calc(var(--calib-x) * 1mm) !important;
    width: 210mm !important;
    height: 297mm !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    page-break-after: avoid;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    transform: none !important;
  }

  /* Re-scale the cells in physical millimeters */
  .sticker-cell {
    width: calc(var(--width) * 1mm) !important;
    height: calc(var(--height) * 1mm) !important;
    left: calc(var(--cell-left) * 1mm) !important;
    top: calc(var(--cell-top) * 1mm) !important;
  }

  .sticker-cell-guide {
    display: none !important;
  }

  /* If faint guides explicitly activated */
  .print-guides-active .sticker-cell-guide.cell-cut-guide {
    display: block !important;
    width: calc((var(--width) - 2 * var(--bleed)) * 1mm) !important;
    height: calc((var(--height) - 2 * var(--bleed)) * 1mm) !important;
    left: calc((var(--cell-left) + var(--bleed)) * 1mm) !important;
    top: calc((var(--cell-top) + var(--bleed)) * 1mm) !important;
    border: 0.1mm dashed rgba(0, 0, 0, 0.25) !important;
  }
}
