/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
  /* Dashboard UI Colors (Dark Mode Theme) */
  --db-bg: #0b0f19;
  --db-card-bg: rgba(20, 26, 46, 0.6);
  --db-border: rgba(255, 255, 255, 0.08);
  --db-border-hover: rgba(255, 255, 255, 0.16);
  --db-text: #f3f4f6;
  --db-text-muted: #9ca3af;
  --db-accent: #3b82f6;
  --db-accent-hover: #2563eb;
  --db-danger: #ef4444;
  --db-success: #10b981;
  --sidebar-width: 440px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Physical Preview Variables - Overwritten by JS/Preset */
  --card-bg: #f4f6f0;
  --card-accent: #2d5a27;
  --card-text: #2d5a27;
}

/* ==========================================================================
   GLOBAL RESET & INITIAL STYLING
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--db-bg);
  color: var(--db-text);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   APP LAYOUT (WEB MODE)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--db-bg);
}
::-webkit-scrollbar-thumb {
  background: #1f2937;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #374151;
}

/* ==========================================================================
   SIDEBAR EDITOR PANEL
   ========================================================================== */
.editor-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #111827 0%, #0b0f17 100%);
  border-right: 1px solid var(--db-border);
  height: 100vh;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: flex-direction;
  flex-flow: column nowrap;
  gap: 2rem;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.editor-header {
  border-bottom: 1px solid var(--db-border);
  padding-bottom: 1.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon-wrapper {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  padding: 0.6rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.logo-icon {
  width: 24px;
  height: 24px;
  color: #fff;
}

.logo-title {
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-subtitle {
  font-size: 0.8rem;
  color: var(--db-text-muted);
}

/* ==========================================================================
   FORM INPUT STYLES (GLASSMORPHISM)
   ========================================================================== */
.editor-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.form-section {
  background: var(--db-card-bg);
  border: 1px solid var(--db-border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-section:hover {
  border-color: var(--db-border-hover);
  box-shadow: var(--shadow-md);
}

.section-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.6rem;
}

.section-icon {
  width: 18px;
  height: 18px;
  color: var(--db-accent);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f3f4f6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.half-width {
  flex: 1;
}

.third-width {
  flex: 1;
}

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--db-text-muted);
}

input[type="text"],
input[type="password"],
select {
  background-color: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--db-border);
  border-radius: 8px;
  color: #fff;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--db-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Password Input with eye icon */
.password-input-wrapper {
  position: relative;
  display: flex;
}

.password-input-wrapper input {
  padding-right: 2.75rem;
}

.password-input-wrapper .icon-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--db-text-muted);
  cursor: pointer;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.password-input-wrapper .icon-btn:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.05);
}

/* Checkbox Styling */
.checkbox-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  padding-top: 1.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--db-text);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--db-accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ==========================================================================
   THEME SELECTOR CARDS
   ========================================================================== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.theme-option {
  cursor: pointer;
  position: relative;
}

.theme-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-card {
  border: 2px solid var(--db-border);
  border-radius: 12px;
  padding: 1rem 0.5rem;
  text-align: center;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  font-weight: 600;
  background-size: cover;
  position: relative;
  overflow: hidden;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1;
  transition: background 0.2s ease;
}

.theme-name {
  position: relative;
  z-index: 2;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Thumbnails Background representations */
.classic-cozy-thumb {
  background: #f4f6f0;
  border-color: #d1d5db;
}
.classic-cozy-thumb .theme-name { color: #2d5a27; text-shadow: none; }
.classic-cozy-thumb::before { background: transparent; }

.minimalist-modern-thumb {
  background: #ffffff;
  border-color: #222;
}
.minimalist-modern-thumb .theme-name { color: #222; text-shadow: none; }
.minimalist-modern-thumb::before { background: transparent; }

.retro-vibe-thumb {
  background: #f7f2ea;
  border-color: #c9623b;
}
.retro-vibe-thumb .theme-name { color: #c9623b; text-shadow: none; }
.retro-vibe-thumb::before { background: transparent; }

.forest-retreat-thumb {
  background: #1e352f;
}
.forest-retreat-thumb .theme-name { color: #fdfcf7; text-shadow: none; }
.forest-retreat-thumb::before { background: rgba(0, 0, 0, 0.1); }

.vibrant-gradient-thumb {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.vibrant-gradient-thumb::before { background: rgba(0, 0, 0, 0.15); }

/* Theme selections states */
.theme-option input[type="radio"]:checked + .theme-card {
  border-color: var(--db-accent);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
}

/* ==========================================================================
   COLOR PALETTES
   ========================================================================== */
.preset-palettes-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.palette-preset {
  cursor: pointer;
  position: relative;
}

.palette-preset input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.palette-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--db-border);
  overflow: hidden;
  display: flex;
  transition: all 0.2s ease;
  position: relative;
}

.palette-swatch div {
  flex: 1;
  height: 100%;
}

.palette-preset input[type="radio"]:checked + .palette-swatch {
  border-color: var(--db-accent);
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.custom-swatch {
  background-color: #1a2035;
  align-items: center;
  justify-content: center;
  color: var(--db-text-muted);
}

.custom-swatch .plus-icon {
  width: 16px;
  height: 16px;
}

.custom-color-controls {
  animation: slideDown 0.2s ease-out;
  padding-top: 0.5rem;
}

.custom-color-controls input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 100%;
  height: 40px;
  border-radius: 8px;
  background-color: transparent;
  cursor: pointer;
}

.custom-color-controls input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.custom-color-controls input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--db-border);
  border-radius: 8px;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   ICON SELECTOR GRID
   ========================================================================== */
.icon-selector-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

.icon-option {
  cursor: pointer;
  position: relative;
}

.icon-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.icon-box {
  border: 1px solid var(--db-border);
  border-radius: 8px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(17, 24, 39, 0.4);
  transition: all 0.2s;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--db-text-muted);
}

.icon-box i {
  width: 18px;
  height: 18px;
}

.icon-option input[type="radio"]:checked + .icon-box {
  border-color: var(--db-accent);
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--db-accent);
}

/* ==========================================================================
   PRINT LAYOUT SELECTOR
   ========================================================================== */
.layout-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.layout-option {
  cursor: pointer;
  position: relative;
}

.layout-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.layout-box {
  border: 1px solid var(--db-border);
  border-radius: 12px;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background-color: rgba(17, 24, 39, 0.4);
  color: var(--db-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  transition: all 0.2s;
}

.layout-box i {
  width: 20px;
  height: 20px;
}

.layout-option input[type="radio"]:checked + .layout-box {
  border-color: var(--db-accent);
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--db-accent);
  font-weight: 600;
}

/* ==========================================================================
   STORAGE / BUTTONS STYLING
   ========================================================================== */
.security-warning {
  display: flex;
  gap: 0.5rem;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  color: #fca5a5;
  font-size: 0.75rem;
  line-height: 1.35;
  animation: slideDown 0.2s ease-out;
}

.security-warning i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.security-opt-in {
  padding-top: 0;
}

.sidebar-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.primary-btn,
.secondary-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
  flex: 1;
}

.primary-btn {
  background-color: var(--db-accent);
  border: 1px solid transparent;
  color: #fff;
}

.primary-btn:hover {
  background-color: var(--db-accent-hover);
}

.secondary-btn {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--db-border);
  color: var(--db-text);
}

.secondary-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--db-border-hover);
}

.sidebar-footer {
  border-top: 1px solid var(--db-border);
  padding-top: 1rem;
  font-size: 0.75rem;
  text-align: center;
  color: var(--db-text-muted);
}

/* ==========================================================================
   RIGHT PREVIEW PANEL STAGE
   ========================================================================== */
.preview-stage {
  flex: 1;
  background-color: #111827;
  padding: 2rem;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

/* Sticky top preview navbar */
.preview-sticky-controls {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  max-width: 900px;
  background-color: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--db-border);
  padding: 1rem 1.5rem;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-lg);
}

.controls-left {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.preview-panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.preview-badge {
  font-size: 0.75rem;
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--db-accent);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
  align-self: flex-start;
  letter-spacing: 0.2px;
}

.controls-right {
  display: flex;
  gap: 0.75rem;
}

.preview-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.preview-btn.primary {
  background-color: var(--db-accent);
  color: #fff;
}

.preview-btn.primary:hover {
  background-color: var(--db-accent-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.preview-btn.secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--db-border);
  color: var(--db-text);
}

.preview-btn.secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--db-border-hover);
}

.preview-legend-helper {
  font-size: 0.75rem;
  color: var(--db-text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 900px;
  width: 100%;
}

.preview-legend-helper i {
  width: 14px;
  height: 14px;
  color: var(--db-accent);
  flex-shrink: 0;
}

/* ==========================================================================
   PHYSICAL PRINT WORKSPACE (SCREEN VIEWER)
   ========================================================================== */
.print-workspace-page {
  background-color: #fff;
  border: 1px dashed var(--db-border-hover);
  border-radius: 2px;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Force a standard Letter/A4 Aspect Ratio on Screen */
  width: 793px;  /* ~8.26 inches at 96 DPI (A4 aspect is 1 : 1.414) */
  min-height: 1122px; /* 1.414 * 793 */
  padding: 40px; /* Margins safe zone representation */
  box-sizing: border-box;
}

.sheet-render-target {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   CARD DESIGN LAYOUT SYSTEM
   ========================================================================== */
.wifi-card {
  --card-primary-rgb: 45, 90, 39;
  background-color: var(--card-bg);
  border: 2px solid var(--card-accent);
  border-radius: 20px;
  color: var(--card-text);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Typography styles according to themes */
.card-header-icon {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.card-header-icon i {
  width: 48px;
  height: 48px;
  stroke: var(--card-accent);
}

.card-title {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  z-index: 2;
  line-height: 1.25;
}

.card-subtitle {
  font-size: 1.05rem;
  max-width: 80%;
  margin-bottom: 2rem;
  opacity: 0.85;
  z-index: 2;
  line-height: 1.5;
}

/* QR Code Section wrapper */
.card-qr-container {
  background-color: #ffffff;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  margin-bottom: 2rem;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

/* Rendered Canvas / SVG */
.card-qr-container canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Credentials Table */
.card-credentials {
  z-index: 2;
  width: 80%;
  margin-top: 1rem;
}

.cred-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.cred-label {
  font-weight: 500;
  opacity: 0.7;
}

.cred-val {
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* ==========================================================================
   THEME STYLES SPECIFICS
   ========================================================================== */

/* Theme 1: Classic Cozy */
.wifi-card.theme-classic-cozy {
  font-family: 'Playfair Display', Georgia, serif;
  border: 3px double var(--card-accent);
  border-radius: 16px;
  padding: 3.5rem;
}
.wifi-card.theme-classic-cozy .card-title {
  font-weight: 700;
  font-style: italic;
  font-size: 2.5rem;
}
.wifi-card.theme-classic-cozy .cred-val {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}
.wifi-card.theme-classic-cozy .card-subtitle {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-style: italic;
}
/* Leaf corner ornaments in classic cozy */
.wifi-card.theme-classic-cozy::before {
  content: '✿';
  position: absolute;
  top: 15px;
  left: 15px;
  font-size: 1.5rem;
  opacity: 0.4;
}
.wifi-card.theme-classic-cozy::after {
  content: '✿';
  position: absolute;
  bottom: 15px;
  right: 15px;
  font-size: 1.5rem;
  opacity: 0.4;
}

/* Theme 2: Minimalist Modern */
.wifi-card.theme-minimalist-modern {
  font-family: 'Outfit', sans-serif;
  border: 6px solid var(--card-accent);
  border-radius: 0;
  text-transform: uppercase;
}
.wifi-card.theme-minimalist-modern .card-title {
  font-weight: 900;
  font-size: 2.4rem;
  letter-spacing: -1px;
}
.wifi-card.theme-minimalist-modern .card-subtitle {
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--card-accent);
  padding-bottom: 1.5rem;
}
.wifi-card.theme-minimalist-modern .card-qr-container {
  border-radius: 0;
  border: 2px solid var(--card-accent);
  box-shadow: none;
}
.wifi-card.theme-minimalist-modern .cred-label {
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Theme 3: Retro Vibe */
.wifi-card.theme-retro-vibe {
  font-family: 'DM Serif Display', serif;
  border: 4px solid var(--card-accent);
  border-radius: 32px;
  background-image: radial-gradient(var(--card-accent) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--card-bg);
}
.wifi-card.theme-retro-vibe .card-title {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
  color: var(--card-accent);
}
.wifi-card.theme-retro-vibe .card-subtitle {
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  text-transform: none;
  color: var(--card-text);
  margin-bottom: 1.75rem;
}
.wifi-card.theme-retro-vibe .card-qr-container {
  border-radius: 24px;
  border: 3px solid var(--card-accent);
  transform: rotate(-1.5deg);
  box-shadow: 6px 6px 0px var(--card-accent);
}
.wifi-card.theme-retro-vibe .cred-val {
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
}
.wifi-card.theme-retro-vibe .card-credentials {
  background-color: var(--card-bg);
  border: 2px solid var(--card-accent);
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: 4px 4px 0px var(--card-accent);
}

/* Theme 4: Forest Retreat */
.wifi-card.theme-forest-retreat {
  font-family: 'Playfair Display', serif;
  border: 1px solid var(--card-accent);
  border-radius: 12px;
  padding: 4rem;
}
.wifi-card.theme-forest-retreat::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  border: 1px solid var(--card-accent);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0.6;
}
.wifi-card.theme-forest-retreat .card-title {
  font-weight: 400;
  font-size: 2.5rem;
  letter-spacing: 0.5px;
}
.wifi-card.theme-forest-retreat .card-subtitle {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  text-transform: none;
  opacity: 0.9;
  margin-bottom: 1.5rem;
}
.wifi-card.theme-forest-retreat .card-qr-container {
  box-shadow: 0 4px 20px rgba(45, 90, 39, 0.12);
  border-radius: 50%;
  padding: 2rem;
}
.wifi-card.theme-forest-retreat .cred-val {
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
}

/* Theme 5: Vibrant Gradient */
.wifi-card.theme-vibrant-gradient {
  font-family: 'Outfit', sans-serif;
  color: #ffffff;
  border: none;
  background-image: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border-radius: 30px;
  padding: 3.5rem;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.1);
}
.wifi-card.theme-vibrant-gradient .card-title {
  font-weight: 800;
  font-size: 2.6rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.wifi-card.theme-vibrant-gradient .card-subtitle {
  background-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 2rem;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.wifi-card.theme-vibrant-gradient .card-qr-container {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border-radius: 20px;
}
.wifi-card.theme-vibrant-gradient .card-header-icon i {
  stroke: #ffffff;
}
.wifi-card.theme-vibrant-gradient .cred-label {
  color: rgba(255, 255, 255, 0.8);
}
.wifi-card.theme-vibrant-gradient .cred-val {
  color: #ffffff;
}

/* ==========================================================================
   LAYOUT STRUCTURES (PHYSICAL PREVIEW CONFIGURATION)
   ========================================================================== */
.sheet-render-target {
  height: 100%;
  width: 100%;
}

/* Layout 1: Poster (Full Page) */
.format-poster .sheet-render-target {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.format-poster .wifi-card {
  height: 100%;
  max-height: 1000px;
}

/* Layout 2: Folding Tent Card */
.format-tent .sheet-render-target {
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* Card is on the bottom panel */
  height: 100%;
  position: relative;
}

/* Guidance markers for folding tent card */
.format-tent .sheet-render-target::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 2px dashed #999;
  z-index: 5;
}

.format-tent .sheet-render-target::after {
  content: '▲ FOLD LINE - STANDING TENT CARD ▲';
  position: absolute;
  top: calc(50% - 10px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: #666;
  background-color: #fff;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  z-index: 6;
}

.format-tent .tent-back-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  color: #9ca3af;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px;
  background-color: #fafbfc;
  border: 1px solid #e5e7eb;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-sizing: border-box;
}

.format-tent .wifi-card {
  height: 50%; /* Only fills the bottom half */
  border-top: none;
  border-radius: 0 0 16px 16px;
}

/* Layout 3: Multi Card Grid (4 per page) */
.format-grid .sheet-render-target {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 30px;
  height: 100%;
  width: 100%;
  padding: 10px;
}

.format-grid .wifi-card {
  padding: 1.5rem;
  border-radius: 12px;
  height: 100%;
}

.format-grid .card-title {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.format-grid .card-subtitle {
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
  max-width: 95%;
}

.format-grid .card-qr-container {
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.format-grid .card-header-icon {
  margin-bottom: 0.25rem;
}

.format-grid .card-header-icon i {
  width: 32px;
  height: 32px;
}

.format-grid .card-credentials {
  width: 100%;
  margin-top: 0.25rem;
}

.format-grid .cred-row {
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

/* Retro and Cozy adjustments in grid mode */
.format-grid .wifi-card.theme-classic-cozy {
  padding: 1.5rem;
}
.format-grid .wifi-card.theme-classic-cozy::before,
.format-grid .wifi-card.theme-classic-cozy::after {
  font-size: 0.8rem;
  top: 8px;
  left: 8px;
  bottom: 8px;
  right: 8px;
}
.format-grid .wifi-card.theme-retro-vibe {
  background-size: 16px 16px;
  padding: 1.5rem;
}
.format-grid .wifi-card.theme-retro-vibe .card-qr-container {
  transform: none;
  box-shadow: 3px 3px 0px var(--card-accent);
}
.format-grid .wifi-card.theme-retro-vibe .card-credentials {
  box-shadow: 2px 2px 0px var(--card-accent);
}
.format-grid .wifi-card.theme-forest-retreat {
  padding: 1.5rem;
}
.format-grid .wifi-card.theme-forest-retreat::before {
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
}

/* ==========================================================================
   RESPONSIVENESS (MOBILE SCREEN WEB VIEWER)
   ========================================================================== */
@media (max-width: 1240px) {
  .app-layout {
    flex-direction: column;
  }
  
  .editor-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--db-border);
    padding: 1.5rem;
  }
  
  .preview-stage {
    padding: 1rem;
    height: auto;
    min-height: 100vh;
  }

  .preview-sticky-controls {
    position: static;
    margin-bottom: 1rem;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .controls-right {
    justify-content: space-between;
  }
  
  .print-workspace-page {
    /* Scale down the physical layout wrapper on small screens so it doesn't overflow */
    width: 100%;
    max-width: 600px;
    height: 850px;
    min-height: 850px;
    padding: 20px;
  }

  .format-tent .sheet-render-target::after {
    font-size: 0.5rem;
    padding: 0 5px;
  }

  .format-grid {
    gap: 15px;
  }
}

@media (max-width: 600px) {
  .controls-right {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .print-workspace-page {
    max-width: 100%;
    height: 620px;
    min-height: 620px;
    padding: 10px;
  }
  
  .theme-grid {
    grid-template-columns: 1fr;
  }

  .format-grid .sheet-render-target {
    gap: 10px;
  }

  .format-grid .wifi-card {
    padding: 0.75rem;
  }

  .format-grid .card-title {
    font-size: 1rem;
  }
  .format-grid .card-subtitle {
    display: none;
  }
  .format-grid .card-qr-container {
    padding: 0.4rem;
  }
}

/* ==========================================================================
   PRINT SPECIFIC SYSTEM (MEDIA PRINT OVERRIDES)
   ========================================================================== */
@media print {
  /* Reset general page parameters */
  html, body {
    background-color: #fff !important;
    color: #000 !important;
    width: 210mm;   /* standard A4 width */
    height: 297mm;  /* standard A4 height */
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Force background colors to display */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide web app layout chrome elements */
  #config-panel,
  .preview-sticky-controls,
  .preview-legend-helper {
    display: none !important;
  }

  .app-layout {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }

  .preview-stage {
    padding: 0 !important;
    margin: 0 !important;
    background-color: transparent !important;
    display: block !important;
    height: 100% !important;
  }

  /* Physical workspace layout overrides for exact paper fitting */
  .print-workspace-page {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100vh !important;
    padding: 20mm 15mm !important; /* Proper printing borders margins */
    box-sizing: border-box !important;
    display: block !important;
  }

  .sheet-render-target {
    height: 100% !important;
    width: 100% !important;
  }

  /* Force font visibility and prevent weird formatting */
  .wifi-card {
    box-shadow: none !important;
    page-break-inside: avoid;
  }

  .format-tent .sheet-render-target::before {
    border-top: 1px dashed #666 !important;
  }

  .format-tent .sheet-render-target::after {
    border: 1px solid #666 !important;
    background-color: #fff !important;
  }

  /* Fix grid layouts on physical print */
  .format-grid .sheet-render-target {
    gap: 15mm !important;
    height: 100% !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
  }
}
