/**
 * StencilMaker Pro - Advanced Technical Design
 * Version: 12.0.0
 * Design: Ultra-Modern, Technical, Professional
 */

/* ===== CSS Variables - Light Theme (Default) ===== */
:root {
    /* Primary Technical Blue Palette */
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-light: #e0f2fe;
    --primary-lightest: #f0f9ff;
    --primary-dark: #0369a1;
    --primary-glow: rgba(14, 165, 233, 0.2);
    
    /* Accent Colors - Technical Green */
    --accent-color: #10b981;
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --accent-glow: rgba(16, 185, 129, 0.2);
    
    /* Secondary - Technical Purple */
    --secondary-color: #8b5cf6;
    --secondary-hover: #7c3aed;
    --secondary-light: #ede9fe;
    
    /* Technical Gradients */
    --gradient-primary: linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%);
    --gradient-accent: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-header: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
    --gradient-mesh: radial-gradient(ellipse at top right, rgba(14, 165, 233, 0.1) 0%, transparent 50%),
                     radial-gradient(ellipse at bottom left, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    
    /* Semantic Colors */
    --success-color: #10b981;
    --success-light: #d1fae5;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --info-color: #0ea5e9;
    --info-light: #e0f2fe;
    
    /* Neutral Palette - Cool Grays */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Technical Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-blur: blur(10px);
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-canvas: #fafbfc;
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;
    
    /* Borders */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-dark: #cbd5e1;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.25rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
}

/* ===== Dark Theme Variables ===== */
[data-theme="dark"] {
    /* Primary Technical Cyan Palette */
    --primary-color: #22d3ee;
    --primary-hover: #06b6d4;
    --primary-light: #164e63;
    --primary-lightest: #083344;
    --primary-dark: #67e8f9;
    --primary-glow: rgba(34, 211, 238, 0.3);
    
    /* Accent Colors - Neon Green */
    --accent-color: #4ade80;
    --accent-hover: #22c55e;
    --accent-light: #14532d;
    --accent-glow: rgba(74, 222, 128, 0.3);
    
    /* Secondary - Neon Purple */
    --secondary-color: #a78bfa;
    --secondary-hover: #8b5cf6;
    --secondary-light: #2e1065;
    
    /* Technical Gradients Dark */
    --gradient-primary: linear-gradient(135deg, #22d3ee 0%, #06b6d4 50%, #0891b2 100%);
    --gradient-accent: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    --gradient-header: linear-gradient(180deg, rgba(15,23,42,0.95) 0%, rgba(15,23,42,0.9) 100%);
    --gradient-mesh: radial-gradient(ellipse at top right, rgba(34, 211, 238, 0.15) 0%, transparent 50%),
                     radial-gradient(ellipse at bottom left, rgba(74, 222, 128, 0.15) 0%, transparent 50%);
    
    /* Semantic Colors Dark */
    --success-color: #4ade80;
    --success-light: #14532d;
    --danger-color: #f87171;
    --danger-light: #7f1d1d;
    --warning-color: #fbbf24;
    --warning-light: #78350f;
    --info-color: #22d3ee;
    --info-light: #164e63;
    
    /* Neutral Palette Dark */
    --gray-50: #020617;
    --gray-100: #0f172a;
    --gray-200: #1e293b;
    --gray-300: #334155;
    --gray-400: #475569;
    --gray-500: #64748b;
    --gray-600: #94a3b8;
    --gray-700: #cbd5e1;
    --gray-800: #e2e8f0;
    --gray-900: #f1f5f9;
    
    /* Technical Shadows Dark */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 4px -1px rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 30px rgba(34, 211, 238, 0.3);
    
    /* Glassmorphism Dark */
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    
    /* Backgrounds Dark */
    --bg-primary: #0f172a;
    --bg-secondary: #020617;
    --bg-tertiary: #1e293b;
    --bg-canvas: #0a0f1c;
    
    /* Text Colors Dark */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    
    /* Borders Dark */
    --border-color: #334155;
    --border-light: #1e293b;
    --border-dark: #475569;
}

/* ===== Selection Tool UI - Toolbox completo ===== */
.smp-selection-options {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 10001;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    min-width: 220px;
    overflow: hidden;
}

.smp-selection-options.active {
    display: block;
}

/* Header del toolbox */
.smp-selection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.smp-selection-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.smp-selection-close {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.smp-selection-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Container dei pulsanti */
.smp-selection-buttons {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smp-selection-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
    text-align: left;
}

.smp-selection-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateX(2px);
}

.smp-selection-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.smp-selection-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.smp-selection-btn span {
    flex: 1;
}

/* Pulsante elimina con stile danger */
.smp-selection-btn-danger {
    color: var(--danger-color);
    border-color: rgba(239, 68, 68, 0.3);
}

.smp-selection-btn-danger:hover {
    background: var(--danger-light);
    border-color: var(--danger-color);
    color: var(--danger-color);
    transform: translateX(2px);
}

/* Hover highlight for paths */
.smp-path-hover {
    cursor: pointer !important;
}

/* Selection handles */
.smp-selection-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.smp-selection-handle:active {
    cursor: grabbing;
}

.smp-selection-handle.nw { cursor: nw-resize; }
.smp-selection-handle.n { cursor: n-resize; }
.smp-selection-handle.ne { cursor: ne-resize; }
.smp-selection-handle.e { cursor: e-resize; }
.smp-selection-handle.se { cursor: se-resize; }
.smp-selection-handle.s { cursor: s-resize; }
.smp-selection-handle.sw { cursor: sw-resize; }
.smp-selection-handle.w { cursor: w-resize; }

/* ===== Custom Tool Cursors ===== */
/* Brush - crosshair center with circle */
.smp-cursor-brush {
    cursor: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><line x1="16" y1="0" x2="16" y2="32" stroke="%23000" stroke-width="1" opacity="0.5"/><line x1="0" y1="16" x2="32" y2="16" stroke="%23000" stroke-width="1" opacity="0.5"/><circle cx="16" cy="16" r="10" fill="none" stroke="%230ea5e9" stroke-width="2"/><circle cx="16" cy="16" r="2" fill="%230ea5e9"/></svg>') 16 16, crosshair;
}

/* Eraser - crosshair center with dashed circle and X */
.smp-cursor-eraser {
    cursor: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><line x1="16" y1="0" x2="16" y2="32" stroke="%23000" stroke-width="1" opacity="0.5"/><line x1="0" y1="16" x2="32" y2="16" stroke="%23000" stroke-width="1" opacity="0.5"/><circle cx="16" cy="16" r="10" fill="none" stroke="%23ef4444" stroke-width="2" stroke-dasharray="2,2"/><line x1="10" y1="10" x2="22" y2="22" stroke="%23ef4444" stroke-width="2"/><line x1="22" y1="10" x2="10" y2="22" stroke="%23ef4444" stroke-width="2"/></svg>') 16 16, crosshair;
}

/* Select - arrow pointer */
.smp-cursor-select {
    cursor: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M2 2l14 14-5 2-2 5-7-7v-14z" fill="%23fff" stroke="%23000" stroke-width="1.5"/><path d="M2 2l14 14-5 2-2 5-7-7v-14z" fill="%230ea5e9" stroke="%230ea5e9" stroke-width="0.5"/></svg>') 2 2, default;
}

/* Text - I-beam cursor */
.smp-cursor-text {
    cursor: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><line x1="16" y1="4" x2="16" y2="28" stroke="%23000" stroke-width="2"/><line x1="10" y1="4" x2="22" y2="4" stroke="%23000" stroke-width="2"/><line x1="10" y1="28" x2="22" y2="28" stroke="%23000" stroke-width="2"/></svg>') 16 16, text;
}

/* Remove - crosshair with X */
.smp-cursor-remove {
    cursor: url('data:image/svg+xml;utf8,<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><line x1="16" y1="0" x2="16" y2="32" stroke="%23000" stroke-width="1" opacity="0.3"/><line x1="0" y1="16" x2="32" y2="16" stroke="%23000" stroke-width="1" opacity="0.3"/><circle cx="16" cy="16" r="10" fill="rgba(239,68,68,0.3)" stroke="%23ef4444" stroke-width="2"/><line x1="10" y1="10" x2="22" y2="22" stroke="%23fff" stroke-width="3"/><line x1="22" y1="10" x2="10" y2="22" stroke="%23fff" stroke-width="3"/></svg>') 16 16, pointer;
}

/* Dynamic cursor size preview - DISABLED */
.smp-cursor-preview {
    display: none !important;
}

/* ===== Global Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Main App Container ===== */
#stencilvector-app {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.smp-app {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--wp-admin-bar-height, 32px));
    min-height: 500px;
    max-height: calc(100vh - var(--wp-admin-bar-height, 32px));
    background: var(--bg-secondary);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

/* Adjust for WordPress admin bar */
.admin-bar .smp-app {
    --wp-admin-bar-height: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .smp-app {
        --wp-admin-bar-height: 46px;
    }
}

/* Full height on smaller screens */
@media screen and (max-height: 700px) {
    .smp-app {
        height: calc(100vh - var(--wp-admin-bar-height, 32px) - 20px);
        max-height: none;
    }
}

/* Background Mesh Pattern */
.smp-app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-mesh);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

/* ===== Header - Technical Glass Design ===== */
.smp-header {
    background: var(--gradient-header);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-md);
}



.smp-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}



@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

/* Header Controls */
.smp-header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.smp-zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
}

/* Zoom controls positioned at top right */
.smp-zoom-controls-bottom {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    backdrop-filter: var(--glass-blur);
    background: var(--glass-bg);
}

/* Zoom divider */
.smp-zoom-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

/* Dark theme adjustments for bottom zoom controls */
body[data-theme="dark"] .smp-zoom-controls-bottom {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--gray-700);
}

body[data-theme="dark"] .smp-zoom-divider {
    background: var(--gray-600);
}

#zoom-level {
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ===== Main Layout ===== */
.smp-main {
    flex: 1;
    display: flex;
    background: var(--bg-secondary);
    overflow: hidden;
    position: relative;
    z-index: 1;
    min-height: 0; /* Important for flex children */
}

/* Canvas Area */
.smp-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    position: relative;
    overflow: auto;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Important for proper scrolling */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for canvas area */
.smp-canvas-area::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.smp-canvas-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    /* border-radius: var(--radius-full); */
}

.smp-canvas-area::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: var(--radius-full);
    opacity: 0.3;
}

.smp-canvas-area::-webkit-scrollbar-thumb:hover {
    opacity: 0.5;
}

/* Gallery Section */
.smp-gallery-section {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.smp-gallery-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.smp-gallery-header h4::before {
    content: '📁';
    font-size: 1.125rem;
}

/* Modern Gallery Grid */
.smp-modern-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    width: 100%;
    max-width: none;
}

.smp-gallery-thumb {
    position: relative;
    width: 120px;
    height: 120px;
    flex: 0 0 120px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.smp-gallery-thumb:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-xl), 0 0 20px var(--primary-glow);
}

.smp-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.smp-gallery-thumb:hover img {
    transform: scale(1.1);
    filter: brightness(1.1);
}

.smp-thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, 
        transparent 0%, 
        transparent 50%, 
        rgba(0, 0, 0, 0.9) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0.75rem;
    opacity: 0;
    transition: var(--transition);
}

.smp-gallery-thumb:hover .smp-thumb-overlay {
    opacity: 1;
}

.smp-thumb-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.125rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.smp-thumb-action {
    font-size: 0.625rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Canvas Container */
.smp-canvas-container {
    position: relative;
    width: auto;
    height: auto;
    /* background: var(--bg-primary); */
    /* border-radius: var(--radius-xl); */
    /* box-shadow: var(--shadow-xl); */
    overflow: visible;
    /* border: 1px solid var(--border-color); */
    display: inline-block;
}

#canvas-container {
    position: relative;
    width: auto;
    height: auto;
    /* background: var(--bg-canvas); */
    display: inline-block;
}

#smp-canvas,
#paper-canvas {
    display: block;
    /* border-radius: var(--radius-xl); */
    border: 2px solid transparent;
    /* background: white; */
}

/* Show red border only in step 2 */
.smp-canvas-area.smp-step-2 #smp-canvas {
    border: 2px solid #ff0000;
}

[data-theme="dark"] #smp-canvas,
[data-theme="dark"] #paper-canvas {
    /* background: #1a1a1a; */
    border: 2px solid transparent;
}

/* Dark theme red border in step 2 */
[data-theme="dark"] .smp-canvas-area.smp-step-2 #smp-canvas {
    border: 2px solid #ff0000;
}

/* Canvas Upload Area */
#canvas-upload-area {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-xl);
    transition: var(--transition);
    cursor: pointer;
    z-index: 10;
}

/* Show upload area only in step 1 */
.smp-step-1 #canvas-upload-area {
    display: flex;
}

/* Hide upload area in other steps */
.smp-step-2 #canvas-upload-area,
.smp-step-3 #canvas-upload-area,
.smp-step-4 #canvas-upload-area {
    display: none !important;
}

/* Upload Container */
.smp-upload-container {
    padding: 2rem;
    text-align: center;
}
.smp-upload-main {
    padding: 40px;
    border: 3px dashed #ccc;
    border-radius: 20px;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.smp-upload-main:hover {
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.smp-canvas-upload.drag-over .smp-upload-main {
    border-color: var(--primary-dark);
    background-color: var(--primary-light);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
}

/* Enhanced upload area styling */
.smp-upload-main .smp-btn {
    font-size: 1.125rem;
    padding: 1rem 2rem;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.smp-upload-main::before {
    content: '📤';
    display: block;
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.smp-upload-main:hover::before {
    opacity: 1;
    animation-duration: 1s;
}

/* Drop hint styling */
.smp-drop-hint {
    margin-top: 1rem;
    color: #666;
    font-size: 0.95rem;
    font-style: italic;
}

/* Make drop area more visible */
.smp-upload-main {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Mobile responsive upload area */
@media (max-width: 768px) {
    .smp-upload-main {
        padding: 30px 20px;
        min-height: 200px;
    }
    
    .smp-upload-main::before {
        font-size: 48px;
        margin-bottom: 15px;
    }
    
    .smp-upload-main .smp-btn {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
    
    .smp-drop-hint {
        font-size: 0.875rem;
    }
}
#canvas-upload-area.drag-over {
    background: var(--primary-light);
    border-color: var(--primary-dark);
    border-style: solid;
    transform: scale(0.98);
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
    opacity: 0.6;
    fill: var(--primary-color);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.upload-text {
    text-align: center;
}

.upload-text h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ===== Sidebar - Technical Panel ===== */
.smp-sidebar {
    width: 380px;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    min-height: 0; /* Important for flex children */
}

/* Sidebar top controls */
.smp-sidebar-top-controls {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    justify-content: center;
    background: var(--bg-secondary);
}

/* New Stencil Button */
.smp-btn-new-stencil {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 2rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 280px;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.smp-btn-new-stencil:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: var(--gradient-accent);
}

.smp-btn-new-stencil:active {
    transform: translateY(0);
}

.smp-btn-new-stencil svg {
    flex-shrink: 0;
}

/* Dark theme adjustments for sidebar top controls */
body[data-theme="dark"] .smp-sidebar-top-controls {
    background: var(--gray-800);
    border-bottom-color: var(--gray-700);
}

body[data-theme="dark"] .smp-btn-new-stencil {
    background: var(--gradient-accent);
}

body[data-theme="dark"] .smp-btn-new-stencil:hover {
    background: var(--gradient-primary);
}

/* Responsive sidebar width */
@media (max-width: 1400px) {
    .smp-sidebar {
        width: 340px;
    }
}

@media (max-width: 1200px) {
    .smp-sidebar {
        width: 320px;
    }
}

/* Steps Navigation */
.smp-steps {
    display: flex;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
}

.smp-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    position: relative;
    opacity: 0.5;
    transition: var(--transition);
    user-select: none;
}

.smp-step:hover {
    opacity: 0.8;
}

.smp-step.active {
    opacity: 1;
}

.smp-step.active:hover {
    opacity: 1;
}

.smp-step::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: var(--transition);
}

.smp-step.active::after {
    transform: scaleX(1);
}

.smp-step-number {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    transition: var(--transition);
}

.smp-step.active .smp-step-number {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.smp-step span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.smp-step.active span {
    color: var(--text-primary);
}

/* Step Circle (replacing step-number) */
.smp-step-circle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    transition: var(--transition);
}

.smp-step.active .smp-step-circle {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.smp-step-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.smp-step.active .smp-step-label {
    color: var(--text-primary);
}

/* Panels */
.smp-panel {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--bg-primary);
    min-height: 0; /* Important for proper scrolling */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Panel scrollbar styling */
.smp-panel::-webkit-scrollbar {
    width: 6px;
}

.smp-panel::-webkit-scrollbar-track {
    background: transparent;
}

.smp-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.smp-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.smp-panel h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.smp-panel h3::before {
    content: '';
    width: 4px;
    height: 1.5rem;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
}

/* ===== Buttons - Technical Design ===== */
.smp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.smp-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.smp-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Button Variants */
.smp-btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md), 0 0 15px var(--primary-glow);
}

.smp-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 20px var(--primary-glow);
}

.smp-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.smp-btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.smp-btn-success {
    background: var(--gradient-accent);
    color: white;
    box-shadow: var(--shadow-md), 0 0 15px var(--accent-glow);
}

.smp-btn-accent {
    background: var(--secondary-color);
    color: white;
    box-shadow: var(--shadow-md), 0 0 15px rgba(139, 92, 246, 0.3);
}

.smp-btn-accent:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(139, 92, 246, 0.4);
}

.smp-btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Button Sizes */
.smp-btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
}

.smp-btn-large {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.smp-btn-block {
    width: 100%;
}

/* Theme Toggle Button */
#theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: rotate(180deg);
}

.theme-icon-light,
.theme-icon-dark {
    font-size: 1.25rem;
}

/* ===== Forms - Technical Style ===== */
.smp-form-group {
    margin-bottom: 1.5rem;
}

.smp-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.smp-form-control,
.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.smp-form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    outline: none;
    margin: 1rem 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--gradient-primary);
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg), 0 0 15px var(--primary-glow);
}

/* ===== Preview Grid ===== */
.smp-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.smp-preview-option {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    transform: scale(1);
}

.smp-preview-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 15px var(--primary-glow);
}

.smp-preview-option:active {
    transform: translateY(0) scale(0.98);
    transition: transform 0.1s ease;
}

.smp-preview-option.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.smp-preview-option.selected::after {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: var(--shadow-md);
}

.smp-preview-canvas {
    width: 100%;
    height: 120px;
    background: white;
}

[data-theme="dark"] .smp-preview-canvas {
    background: #1a1a1a;
}

.smp-preview-info {
    padding: 0.75rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.smp-preview-info h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.smp-preview-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}


/* ===== Tools Panel ===== */
.smp-tools-section {
    margin-bottom: 1.5rem;
}

.smp-tools {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.smp-tool {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.25rem;
}

.smp-tool:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.smp-tool.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

/* ===== Status Messages ===== */
#smp-status {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
}

.smp-status-message {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2xl);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease;
    pointer-events: all;
}

@keyframes slideIn {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.smp-status-message.success {
    border-left-color: var(--success-color);
}

.smp-status-message.error {
    border-left-color: var(--danger-color);
}

/* ===== Loading States ===== */
.smp-loading,
.smp-preview-loader,
.smp-loading-indicator {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    z-index: 1000;
}

.smp-loading-indicator {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.smp-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Professional Verification ===== */
.smp-verification-option {
    background: var(--gradient-primary);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: var(--transition);
    color: white;
    box-shadow: var(--shadow-md), 0 0 20px var(--primary-glow);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.smp-verification-option:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 30px var(--primary-glow);
}

.smp-verification-option input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: white;
}

/* ===== Application Method ===== */
.smp-application-method {
    transition: var(--transition);
}

.smp-application-method h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.smp-application-method input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

.smp-application-method label {
    transition: var(--transition);
}

.smp-application-method label:hover {
    background: rgba(255,255,255,0.1) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.smp-application-method label:has(input:checked) {
    border-color: var(--primary-color) !important;
    background: rgba(14, 165, 233, 0.2) !important;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ===== Physical Delivery ===== */
.smp-physical-delivery {
    transition: var(--transition);
}

.smp-physical-delivery:hover {
    background: rgba(34, 197, 94, 0.2) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.smp-physical-delivery input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: #22c55e;
}

.smp-physical-delivery input[type="checkbox"]:checked ~ div {
    color: #22c55e;
}

#physical-delivery-price {
    font-weight: 600;
    color: #22c55e;
}

#physical-price-details {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}


/* Make inputs readonly in step 4 */
.smp-step-4 .smp-dimension-value input {
    pointer-events: none;
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    cursor: default;
}

/* Style the display spans for step 4 */
.smp-dimension-display {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    font-family: var(--font-mono);
    min-width: 60px;
    text-align: right;
}


/* ===== Product Box ===== */
.smp-product-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-lg);
}

.smp-product-price {
    text-align: center;
    margin-bottom: 1rem;
}

.smp-product-price .woocommerce-Price-amount {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.smp-total-price {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    padding: 1.25rem;
    background: #004cff;
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

/* ===== Dimensions Display ===== */
.smp-dimensions-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
}

.smp-dimension-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.smp-dimension-row + .smp-dimension-row {
    border-top: 1px solid var(--border-light);
}

.smp-dimension-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.smp-dimension-value {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary-color);
}

/* ===== Utility Classes ===== */
.smp-hidden { display: none !important; }
.smp-text-center { text-align: center; }
.smp-text-muted { color: var(--text-muted); }
.smp-mt-10 { margin-top: 0.625rem; }
.smp-mt-20 { margin-top: 1.25rem; }
.smp-mb-10 { margin-bottom: 0.625rem; }
.smp-mb-20 { margin-bottom: 1.25rem; }

/* ===== Responsive Design ===== */
@media (max-width: 1280px) {
    .smp-sidebar {
        width: 340px;
    }
}

@media (max-width: 1024px) {
    .smp-app {
        height: calc(100vh - var(--wp-admin-bar-height, 32px));
    }
    
    .smp-main {
        flex-direction: column;
    }
    
    .smp-sidebar {
        width: 100%;
        height: 40vh;
        max-height: 400px;
        min-height: 300px;
        border-left: none;
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .smp-canvas-area {
        min-height: 50vh;
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .smp-app {
        height: calc(100vh - var(--wp-admin-bar-height, 46px));
        min-height: auto;
    }
    
    .smp-header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .smp-header h1 {
        font-size: 1.25rem;
    }
    
    .smp-header-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .smp-sidebar {
        width: 100%;
        height: 45vh;
        max-height: none;
    }
    
    .smp-canvas-area {
        padding: 0.75rem;
        min-height: 40vh;
    }
    
    .smp-modern-gallery {
        display: flex;
        flex-wrap: wrap;
    }
    
    /* Fixed toolbar on mobile */
    .smp-fixed-toolbar {
        bottom: 20px;
        left: 50%;
        top: auto;
        transform: translateX(-50%);
        flex-direction: row;
        padding: 12px;
        border-radius: var(--radius-full);
        max-width: 90vw;
    }
    
    .smp-toolbar-inner {
        flex-direction: row;
        gap: 8px;
    }
    
    .smp-toolbar-divider {
        width: 1px;
        height: 32px;
    }
    
    .smp-size-control {
        flex-direction: row;
    }
    
    .smp-unit-control {
        flex-direction: row;
        gap: 6px;
    }
    
    .smp-unit-control label {
        display: none; /* Nascondi label su mobile per risparmiare spazio */
    }
    
    .smp-unit-select {
        width: 45px;
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .smp-header-controls {
        gap: 0.5rem;
    }
    
    .smp-preview-grid {
        grid-template-columns: 1fr;
    }
    
    .smp-tools {
        grid-template-columns: repeat(3, 1fr);
    }
    
    #smp-status {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Viewport Height Fix for Mobile ===== */
/* Fix for mobile browsers with dynamic viewport */
.smp-app {
    height: 100vh;
    height: -webkit-fill-available;
    height: -moz-available;
    height: fill-available;
}

/* Adjust for admin bar */
.admin-bar .smp-app {
    height: calc(100vh - 32px);
    height: calc(-webkit-fill-available - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar .smp-app {
        height: calc(100vh - 46px);
        height: calc(-webkit-fill-available - 46px);
    }
}

/* ===== Landscape Mode Optimization ===== */
@media (orientation: landscape) and (max-height: 600px) {
    .smp-app {
        min-height: auto;
    }
    
    .smp-header {
        padding: 0.5rem 1rem;
    }
    
    .smp-sidebar {
        height: 35vh;
        min-height: 200px;
    }
    
    .smp-canvas-area {
        min-height: 35vh;
    }
}

/* ===== Focus Styles ===== */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== Upload History Grid ===== */
.smp-upload-history {
    margin-top: 1rem;
}

.smp-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.smp-upload-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
    cursor: pointer;
}

.smp-upload-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.smp-upload-thumb {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    position: relative;
}

.smp-upload-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.smp-upload-thumb.smp-upload-thumb-stencil img {
    background: white;
    padding: 0.5rem;
}

.smp-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.smp-upload-item:hover .smp-upload-overlay {
    opacity: 1;
}

.smp-upload-info {
    flex: 1;
}

.smp-upload-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.smp-upload-status {
    font-size: 0.625rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.smp-upload-status.completed {
    background: var(--success-light);
    color: var(--success-color);
}

.smp-upload-status.processing {
    background: var(--warning-light);
    color: var(--warning-color);
}

.smp-upload-dimensions {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.smp-upload-date {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.smp-upload-actions {
    display: flex;
    gap: 0.25rem;
}

.smp-btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
}

/* History section header */
.smp-history-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.smp-history-icon {
    font-size: 1.25rem;
}

/* Dark theme adjustments */
body[data-theme="dark"] .smp-upload-item {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .smp-upload-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body[data-theme="dark"] .smp-upload-thumb {
    background: rgba(0, 0, 0, 0.3);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .smp-upload-grid {
        grid-template-columns: 1fr;
    }
}

/* Info Box */
.smp-info-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.smp-info-box strong {
    color: var(--text-primary);
}

.smp-info-box small {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

body[data-theme="dark"] .smp-info-box {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ===== Print Styles ===== */
@media print {
    .smp-header,
    .smp-sidebar,
    #smp-status {
        display: none !important;
    }
}

/* ===== SVG Reset and Fix ===== */
.smp-fixed-toolbar svg,
.smp-tool-btn svg {
    /* Reset any potential conflicts */
    transform: none !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
    -webkit-mask: none !important;
    mask: none !important;
    clip-path: none !important;
}

/* Ensure SVG container doesn't hide content */
.smp-tool-btn {
    line-height: 1 !important;
    font-size: 0 !important; /* Hide any text */
}

/* Force display of SVG content */
.smp-tool-btn svg,
.smp-tool-btn svg * {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Alternative icon solution with CSS */
.smp-tool-btn[id="tool-brush-float"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: currentColor;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2L19 9L12 16L5 9L12 2Z M12 16V22"/></svg>') center/contain no-repeat;
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2L19 9L12 16L5 9L12 2Z M12 16V22"/></svg>') center/contain no-repeat;
}

.smp-tool-btn[id="tool-eraser-float"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: currentColor;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 20H7L2 15L13 4L20 11L11 20M7 20H20"/></svg>') center/contain no-repeat;
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 20H7L2 15L13 4L20 11L11 20M7 20H20"/></svg>') center/contain no-repeat;
}

.smp-tool-btn[id="tool-remove-float"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: currentColor;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 8L16 16M16 8L8 16"/></svg>') center/contain no-repeat;
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M8 8L16 16M16 8L8 16"/></svg>') center/contain no-repeat;
}

/* Hide SVG if mask works */
.smp-tool-btn[id="tool-brush-float"]:has(::after) svg,
.smp-tool-btn[id="tool-eraser-float"]:has(::after) svg,
.smp-tool-btn[id="tool-remove-float"]:has(::after) svg {
    display: none !important;
}

/* ===== Fixed Tools Container ===== */
.smp-fixed-tools-container {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

/* ===== Fixed Toolbar Styles ===== */
.smp-fixed-toolbar {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    padding: 6px;
    display: none;
    max-height: 80vh;
    overflow-y: auto;
    width: 48px;
}

body[data-theme="dark"] .smp-fixed-toolbar {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

/* Ensure container doesn't overlap with WP admin bar */
@media screen and (min-width: 601px) {
    .admin-bar .smp-fixed-tools-container {
        top: calc(50% + 16px);
    }
}

@media screen and (max-width: 600px) {
    .admin-bar .smp-fixed-tools-container {
        top: calc(50% + 23px);
    }
}

body[data-theme="dark"] .smp-fixed-toolbar {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Show toolbar only in step 3 */
.smp-step-3 .smp-fixed-toolbar {
    display: block;
}

.smp-toolbar-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.smp-toolbar-divider {
    width: 100%;
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
    opacity: 0.5;
}

body[data-theme="dark"] .smp-toolbar-divider {
    background: rgba(255, 255, 255, 0.1);
}

.smp-toolbar-spacer {
    flex-grow: 1;
    min-height: 10px;
}

/* Size control styles */
.smp-size-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 4px 0;
}

.smp-size-control label {
    font-size: 10px;
    color: var(--text-secondary);
    margin: 0;
}

.smp-size-input {
    width: 36px;
    height: 24px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 11px;
    text-align: center;
}

.smp-size-unit {
    font-size: 9px;
    color: var(--text-secondary);
}

/* Unit control styles */
.smp-unit-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 4px 0;
}

.smp-unit-control label {
    font-size: 10px;
    color: var(--text-secondary);
    margin: 0;
}

.smp-unit-select {
    width: 36px;
    height: 24px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 11px;
}

/* Tool Buttons */
.smp-tool-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
}

/* Tooltip styles for tool buttons */
.smp-tool-btn::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.smp-tool-btn:hover::after {
    opacity: 1;
}

.smp-tool-btn:hover {
    background: var(--primary-lightest);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.smp-tool-btn.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.3);
    transform: scale(1.05);
}

/* Dark theme tool buttons */
body[data-theme="dark"] .smp-tool-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] .smp-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    color: white;
}

body[data-theme="dark"] .smp-tool-btn.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

/* SVG Icon Styles - Fixed */
.smp-tool-btn svg {
    width: 16px !important;
    height: 16px !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: none;
    vertical-align: middle;
}

.smp-tool-btn svg path,
.smp-tool-btn svg line,
.smp-tool-btn svg circle,
.smp-tool-btn svg polyline {
    stroke: #475569 !important;
    fill: none !important;
    stroke-width: 2px !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.smp-tool-btn:hover svg path,
.smp-tool-btn:hover svg line,
.smp-tool-btn:hover svg circle,
.smp-tool-btn:hover svg polyline {
    stroke: #0ea5e9 !important;
}

.smp-tool-btn.active svg path,
.smp-tool-btn.active svg line,
.smp-tool-btn.active svg circle,
.smp-tool-btn.active svg polyline {
    stroke: white !important;
}

/* Force color for light theme */
.smp-tool-btn svg {
    color: #475569;
}

.smp-tool-btn:hover svg {
    color: #0ea5e9;
}

.smp-tool-btn.active svg {
    color: white;
}

/* Fallback icons if SVG fails */
.smp-tool-btn[data-tool="brush"]::before {
    content: "🖌️";
    font-size: 18px;
    position: absolute;
    display: none;
}

.smp-tool-btn[data-tool="eraser"]::before {
    content: "🧹";
    font-size: 18px;
    position: absolute;
    display: none;
}

.smp-tool-btn[data-tool="remove"]::before {
    content: "❌";
    font-size: 16px;
    position: absolute;
    display: none;
}

/* Show fallback if SVG is not visible */
.smp-tool-btn:not(:has(svg:not(:empty)))::before {
    display: block;
}

/* Dark theme SVG styles */
body[data-theme="dark"] .smp-tool-btn svg path,
body[data-theme="dark"] .smp-tool-btn svg line,
body[data-theme="dark"] .smp-tool-btn svg circle,
body[data-theme="dark"] .smp-tool-btn svg polyline {
    stroke: rgba(255, 255, 255, 0.7) !important;
}

body[data-theme="dark"] .smp-tool-btn:hover svg path,
body[data-theme="dark"] .smp-tool-btn:hover svg line,
body[data-theme="dark"] .smp-tool-btn:hover svg circle,
body[data-theme="dark"] .smp-tool-btn:hover svg polyline {
    stroke: white !important;
}

body[data-theme="dark"] .smp-tool-btn.active svg path,
body[data-theme="dark"] .smp-tool-btn.active svg line,
body[data-theme="dark"] .smp-tool-btn.active svg circle,
body[data-theme="dark"] .smp-tool-btn.active svg polyline {
    stroke: white !important;
}

/* Debug: Force SVG visibility */
.smp-fixed-toolbar svg {
    min-width: 20px !important;
    min-height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
}

/* Tooltips for tool buttons */
.smp-tool-btn {
    position: relative;
}

.smp-tool-btn::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) scale(0.9);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
}

.smp-tool-btn:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* Mobile tooltips on top */
@media (max-width: 768px) {
    .smp-tool-btn::after {
        left: 50%;
        top: auto;
        bottom: calc(100% + 10px);
        transform: translateX(-50%) scale(0.9);
    }
    
    .smp-tool-btn:hover::after {
        transform: translateX(-50%) scale(1);
    }
}

/* Size Control */
.smp-size-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

/* Unit Control */
.smp-unit-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* ===== Shift Indicator ===== */
.smp-shift-indicator {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 6px 12px;
    font-size: 12px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    animation: slideInUp 0.2s ease;
    z-index: 100;
}

.smp-shift-indicator i {
    font-size: 14px;
}

/* Dark theme shift indicator */
[data-theme="dark"] .smp-shift-indicator {
    background: var(--glass-bg);
    color: var(--primary-color);
}

.smp-unit-control label {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.smp-unit-select {
    width: 42px;
    padding: 2px 3px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: black;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 12 12"><path fill="%23000000" d="M2 4l4 4 4-4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 2px center;
    padding-right: 14px;
}

/* Dropdown menu styles for light theme */
.smp-unit-select option {
    background: white !important;
    color: black !important;
}

.smp-unit-select:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.smp-unit-select:focus {
    outline: none;
    background-color: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Dark theme unit control */
body[data-theme="dark"] .smp-unit-select {
    background-color: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 12 12"><path fill="%23ffffff" d="M2 4l4 4 4-4z"/></svg>');
}

body[data-theme="dark"] .smp-unit-select option {
    background: #1e293b !important;
    color: white !important;
}

body[data-theme="dark"] .smp-unit-select:hover {
    background-color: #334155;
}

body[data-theme="dark"] .smp-unit-select:focus {
    background-color: #1e293b;
}

.smp-size-control label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 1px;
}

.smp-size-input {
    width: 42px;
    padding: 2px 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    transition: var(--transition);
    -moz-appearance: textfield;
}

.smp-size-input::-webkit-outer-spin-button,
.smp-size-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.smp-size-input:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.smp-size-input:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.smp-size-unit {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dark theme size control */
body[data-theme="dark"] .smp-size-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

body[data-theme="dark"] .smp-size-input:hover {
    background: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .smp-size-input:focus {
    background: rgba(255, 255, 255, 0.05);
}

/* ===== Islands Alert Removed ===== */
/* Islands detection still works for structural analysis */

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Dimensions Overlay ===== */
.smp-dimensions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    display: none;
    overflow: visible;
}

/* Show in step 3 */
.smp-canvas-container.smp-step-3 .smp-dimensions-overlay {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 100 !important;
}

.smp-dimension-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible !important;
    pointer-events: none;
}

.smp-dimension-lines line {
    stroke: #ef4444;
    stroke-width: 2px;
    opacity: 0.8;
    filter: drop-shadow(0 0 3px rgba(239, 68, 68, 0.5));
}

.smp-dimension-lines .stencil-dimensions line {
    stroke: #ef4444;
}

.smp-dimension-lines .design-dimensions line {
    stroke: #10b981;
}

/* Dimension Values */
.smp-dimension-value {
    position: absolute;
    display: none;
    align-items: center;
    gap: 6px;
    pointer-events: all !important;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    z-index: 100;
    border: 2px solid transparent;
    transition: var(--transition-fast);
}

body[data-theme="dark"] .smp-dimension-value {
    background: rgba(30, 41, 59, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.smp-dimension-value:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

/* Show dimension values in step 3 */
.smp-canvas-container.smp-step-3 .smp-dimension-value {
    display: flex !important;
}

/* Editable hole dimension values styling */
.smp-dimension-value {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
}

body[data-theme="dark"] .smp-dimension-value {
    background: rgba(14, 165, 233, 0.15);
}

.smp-dimension-display {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
    text-align: center;
}

.smp-dimension-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 8px;
}

.smp-dimension-unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.smp-inline-input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    /* color: var(--text-primary); */
    transition: all 0.2s ease;
    outline: none;
    border-radius: var(--radius-md);
    cursor: text;
    min-width: 60px;
}

.smp-inline-input:hover {
    background: rgba(14, 165, 233, 0.05);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
    color: white;
}

.smp-inline-input:focus {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2),
                0 2px 8px rgba(14, 165, 233, 0.15);
    transform: translateY(-1px);
}

.smp-inline-input:active {
    transform: translateY(0);
}

/* Hide spinners for cleaner look */
.smp-inline-input::-webkit-outer-spin-button,
.smp-inline-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.smp-inline-input {
    -moz-appearance: textfield;
}

/* Error state for invalid values */
.smp-inline-input.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) translateY(-1px); }
    25% { transform: translateX(-2px) translateY(-1px); }
    75% { transform: translateX(2px) translateY(-1px); }
}

/* Dark theme variants */
body[data-theme="dark"] .smp-inline-input {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--gray-600);
    /* color: var(--gray-100); */
}

body[data-theme="dark"] .smp-inline-input:hover {
    background: rgba(14, 165, 233, 0.1);
}

body[data-theme="dark"] .smp-inline-input:focus {
    background: rgba(14, 165, 233, 0.15);
}

.smp-unit {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

/* Dimension Lock Buttons */
.smp-dimension-lock {
    position: absolute;
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: all;
    font-size: 16px;
    transition: var(--transition);
    box-shadow: var(--shadow-glow);
    color: white;
    gap: 2px;
}

.smp-dimension-lock small {
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.9;
}

.smp-dimension-lock:hover {
    transform: scale(1.05);
}

.smp-dimension-lock.unlocked {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-md);
    color: var(--text-secondary);
}

/* Position the two lock buttons */
.smp-stencil-lock {
    bottom: 20px;
    right: 80px;
}

.smp-design-lock {
    bottom: 20px;
    right: 20px;
}

.smp-canvas-container.smp-step-3 .smp-dimension-lock {
    display: flex !important;
}

/* Paper Canvas Styles */
#paper-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    background: transparent;
    z-index: 2;
    cursor: crosshair;
}

/* Step 3 visibility */
.smp-step-3 #smp-canvas {
    display: none !important;
}

.smp-step-3 #paper-canvas {
    display: block !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Islands */
.smp-island {
    fill: #ef4444 !important;
    fill-opacity: 0.8 !important;
    stroke: #dc2626 !important;
    stroke-width: 2px !important;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.5));
    animation: islandPulse 2s ease-in-out infinite;
}

@keyframes islandPulse {
    0%, 100% { 
        fill-opacity: 0.8;
        filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.5));
    }
    50% { 
        fill-opacity: 0.95;
        filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.8));
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Invert Button for Phase 2 ===== */
.smp-invert-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    z-index: 20;
}

.smp-invert-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.smp-invert-btn:active {
    transform: scale(0.95);
}

/* Hide invert button by default */
.smp-invert-btn {
    display: none;
}

/* Show only in step 2 when a preset is selected */
.smp-canvas-area.smp-step-2.smp-preset-selected .smp-invert-btn {
    display: flex !important;
}

/* Dark theme adjustments */
[data-theme="dark"] .smp-invert-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .smp-invert-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

/* ===== Panning and Grid Drawing States ===== */
/* Panning cursor states */
.smp-canvas-container.panning {
    cursor: grabbing !important;
}

.smp-canvas-container.pan-ready #paper-canvas {
    cursor: grab !important;
}

/* Grid drawing indicator */
.smp-grid-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}

.smp-grid-indicator.active {
    opacity: 1;
}

/* Dark theme grid indicator */
[data-theme="dark"] .smp-grid-indicator {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

/* ===== Stability Analysis Visualization ===== */
.smp-stability-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.smp-weak-point {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ff6b6b;
    opacity: 0.6;
    transform: translate(-50%, -50%);
    animation: weakPointPulse 2s ease-in-out infinite;
}

.smp-weak-point.critical {
    background: #ff4444;
    opacity: 0.8;
}

@keyframes weakPointPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.9;
    }
}

.smp-suggested-bridge {
    position: absolute;
    background: #51cf66;
    opacity: 0.5;
    transform-origin: left center;
    animation: bridgePulse 3s ease-in-out infinite;
}

@keyframes bridgePulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.8;
    }
}

/* Stability results panel */
.smp-stability-results {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-lg);
    padding: 15px;
    min-width: 250px;
    box-shadow: var(--shadow-xl);
    display: none;
    z-index: 100;
}

[data-theme="dark"] .smp-stability-results {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

.smp-stability-results.active {
    display: block;
}

.smp-stability-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.smp-stability-title {
    font-weight: 600;
    font-size: 14px;
}

.smp-stability-close {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.smp-stability-close:hover {
    opacity: 1;
}

.smp-stability-score {
    text-align: center;
    margin: 15px 0;
}

.smp-stability-percentage {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, #51cf66 0%, #10b981 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.smp-stability-percentage.warning {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.smp-stability-percentage.critical {
    background: linear-gradient(135deg, #ff6b6b 0%, #ef4444 100%);
}

.smp-stability-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.smp-stability-details {
    font-size: 13px;
    line-height: 1.6;
}

.smp-stability-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

.smp-stability-icon {
    font-size: 16px;
}

.smp-stability-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.smp-btn-apply-suggestions {
    width: 100%;
    font-size: 13px;
}

/* Toggle for showing/hiding analysis */
.smp-analysis-toggle {

    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    display: none;
    z-index: 100;
}

.smp-analysis-toggle.active {
    display: flex;
    align-items: center;
    gap: 6px;
}
/* ===== Enhanced Stability Analysis UI ===== */
.smp-stability-toggle {
    margin-bottom: 15px;
}

.smp-stability-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.smp-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.smp-close-btn:hover {
    background: var(--danger-light);
    color: var(--danger-color);
}

.smp-stability-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.smp-stability-actions .smp-btn {
    flex: 1;
    font-size: 12px;
    padding: 8px 12px;
}

/* Warning button style */
.smp-btn-warning {
    background: var(--warning-color);
    color: white;
    border: 1px solid var(--warning-color);
}

.smp-btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

/* Dark theme support */
body[data-theme="dark"] .smp-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ===== Enhanced Stability Analysis UI ===== */
.smp-stability-toggle {
    margin-bottom: 15px;
}

.smp-stability-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.smp-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.smp-close-btn:hover {
    background: var(--danger-light);
    color: var(--danger-color);
}

.smp-stability-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.smp-stability-actions .smp-btn {
    flex: 1;
    font-size: 12px;
    padding: 8px 12px;
}

/* Warning button style */
.smp-btn-warning {
    background: var(--warning-color);
    color: white;
    border: 1px solid var(--warning-color);
}

.smp-btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

/* Dark theme support */
body[data-theme="dark"] .smp-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}/* ===== Real-time Stability Analysis ===== */
.smp-stability-analysis h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.smp-stability-results {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 15px;
}

.smp-stability-score {
    text-align: center;
}

.smp-stability-percentage {
    display: inline-block;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    transition: all 0.3s ease;
    margin-bottom: 5px;
}

.smp-stability-score small {
    display: block;
    margin-top: 5px;
}

.smp-stability-actions {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.smp-stability-actions .smp-btn {
    font-size: 12px;
}

/* Real-time indicator */
.smp-stability-percentage::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-left: 8px;
    opacity: 0.6;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}/* ===== Professional Engineering Analysis Dashboard ===== */
.smp-stability-analysis {
    margin-bottom: 20px;
}

.smp-stability-results {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 15px;
    box-shadow: var(--shadow-sm);
}

/* Metrics Cards */
.smp-stability-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.smp-metric-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
    transition: var(--transition);
}

.smp-metric-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.smp-metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.smp-metric-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Actions */
.smp-stability-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.smp-stability-actions .smp-btn {
    flex: 1;
    font-size: 11px;
    padding: 8px 10px;
}

/* Legend */
.smp-stability-legend {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-top: 10px;
}

.smp-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.smp-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Real-time indicator animation */
@keyframes realtime-pulse {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

.smp-metric-value:not(:empty):not(:-webkit-any([textContent="-"])) {
    position: relative;
}

.smp-metric-value:not(:empty):not(:-webkit-any([textContent="-"]))::after {
    content: '●';
    position: absolute;
    top: -2px;
    right: -12px;
    font-size: 8px;
    color: currentColor;
    animation: realtime-pulse 2s infinite;
}

/* Critical areas overlay styles */
.smp-critical-overlay {
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Dark theme adjustments */
body[data-theme="dark"] .smp-stability-results {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .smp-metric-card {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.05);
}

body[data-theme="dark"] .smp-stability-legend {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ===== Text Tool Dialog ===== */
.smp-text-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.smp-text-dialog-content {
    background: white;
    border-radius: var(--radius-2xl);
    padding: 2.5rem;
    min-width: 450px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.smp-text-dialog-content h3 {
    margin: 0 0 2rem 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.smp-text-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.smp-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.smp-form-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.smp-text-input,
.smp-text-select,
.smp-text-size-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--gray-50);
    color: var(--text-primary);
    transition: var(--transition);
    font-weight: 500;
}

.smp-text-input:hover,
.smp-text-select:hover,
.smp-text-size-input:hover {
    border-color: var(--gray-400);
    background: white;
}

.smp-text-input:focus,
.smp-text-select:focus,
.smp-text-size-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: white;
}

.smp-text-size-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.smp-text-size-input {
    width: 100px;
}

.smp-text-unit {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.smp-text-dialog-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.smp-text-dialog-buttons .smp-btn {
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dark theme for text dialog */
body[data-theme="dark"] .smp-text-dialog-content {
    background: var(--gray-800);
}

body[data-theme="dark"] .smp-text-input,
body[data-theme="dark"] .smp-text-select,
body[data-theme="dark"] .smp-text-size-input {
    background: var(--gray-700);
    border-color: var(--gray-600);
    color: var(--gray-100);
}

body[data-theme="dark"] .smp-text-input:focus,
body[data-theme="dark"] .smp-text-select:focus,
body[data-theme="dark"] .smp-text-size-input:focus {
    border-color: var(--primary-color);
}

/* Text object styles */
.smp-text-object {
    pointer-events: all;
    cursor: move;
}

.smp-text-object.selected {
    stroke: var(--primary-color);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

/* Selection styles - defined in JavaScript for Paper.js */
/* These styles are for reference only, actual styling is done in Paper.js */

/* Visual feedback for selected tools */
.smp-tool-btn[data-tool="select"].active {
    background: var(--primary-color);
    color: white;
}

.smp-tool-btn[data-tool="text"].active {
    background: var(--primary-color);
    color: white;
}

/* Canvas states */
#paper-canvas.selecting {
    cursor: default !important;
}

#paper-canvas.placing-text {
    cursor: crosshair !important;
}

#paper-canvas.moving {
    cursor: move !important;
}

#paper-canvas.rotating {
    cursor: crosshair !important;
}

#paper-canvas.scaling {
    cursor: nwse-resize !important;
}

/* Apply Changes Dialog */
.smp-apply-changes-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.smp-apply-changes-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-color);
}

.smp-apply-changes-content h3 {
    margin: 0 0 1.5rem 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.smp-apply-changes-info p {
    margin: 0 0 1rem 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.smp-changes-list {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid var(--border-light);
}

.smp-warning {
    background: var(--warning-light);
    color: var(--warning-color);
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--warning-color);
    font-size: 0.875rem !important;
}

.smp-apply-changes-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.smp-apply-changes-buttons .smp-btn {
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Selection Controls */
.smp-selection-controls {
    position: fixed;
    top: 120px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: var(--glass-shadow);
    z-index: 100;
    min-width: 180px;
}

.smp-selection-controls .smp-btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius);
    white-space: nowrap;
}

/* Dark theme for apply changes dialog */
body[data-theme="dark"] .smp-apply-changes-content {
    background: var(--gray-800);
    border-color: var(--gray-600);
}

body[data-theme="dark"] .smp-changes-list {
    background: var(--gray-700);
    border-color: var(--gray-600);
}

body[data-theme="dark"] .smp-selection-controls {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(100, 116, 139, 0.3);
}

/* Change item styles */
.change-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-light);
}

.change-item:last-child {
    margin-bottom: 0;
}

.change-icon {
    font-size: 1rem;
}

.change-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

body[data-theme="dark"] .change-item {
    background: var(--gray-600);
    border-color: var(--gray-500);
}

/* Text Control Panel */
.smp-text-control-panel {
    position: fixed;
    top: 120px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    z-index: 200;
    min-width: 280px;
    max-width: 350px;
}

.smp-text-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.smp-text-control-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

.smp-btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.smp-btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.smp-text-control-content {
    padding: 1rem;
}

.smp-text-info {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.smp-text-preview {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.smp-text-details {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.smp-text-controls {
    margin-bottom: 1rem;
}

.smp-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.smp-control-row:last-child {
    margin-bottom: 0;
}

.smp-control-row label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 70px;
}

.smp-position-controls,
.smp-size-controls,
.smp-rotation-controls {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.smp-btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    min-width: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smp-btn-small:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.smp-btn-small:active {
    transform: translateY(1px);
}

#text-current-size {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 2.5rem;
    text-align: center;
}

.smp-text-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.smp-text-actions .smp-btn {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius);
    white-space: nowrap;
}

/* Selection Controls Updates */
.smp-selection-controls {
    position: fixed;
    top: 120px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--glass-shadow);
    z-index: 100;
    min-width: 200px;
}

.smp-selection-controls h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.smp-selection-info {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.smp-selection-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

/* Dark theme for text control panel */
body[data-theme="dark"] .smp-text-control-panel {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(100, 116, 139, 0.3);
}

body[data-theme="dark"] .smp-text-control-header {
    border-color: rgba(100, 116, 139, 0.3);
}

body[data-theme="dark"] .smp-text-info {
    background: var(--gray-700);
    border-color: var(--gray-600);
}

body[data-theme="dark"] .smp-btn-small {
    background: var(--gray-700);
    border-color: var(--gray-600);
    color: var(--gray-200);
}

body[data-theme="dark"] .smp-btn-small:hover {
    background: var(--gray-600);
    border-color: var(--primary-color);
}

body[data-theme="dark"] .smp-selection-controls {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(100, 116, 139, 0.3);
}

body[data-theme="dark"] .smp-selection-info {
    background: var(--gray-700);
}

/* Step 1 clickable when not active and not disabled */
#step-1:not(.active):not(.disabled) {
    cursor: pointer;
    transition: all 0.3s ease;
}

#step-1:not(.active):not(.disabled):hover {
    background: var(--bg-tertiary);
    transform: translateX(5px);
}

#step-1:not(.active):not(.disabled):hover .smp-step-circle {
    background: var(--primary-color);
    color: white;
}

/* Step 1 disabled state */
#step-1.disabled {
    cursor: default;
    opacity: 0.7;
}

/* Processing state styles */
body.processing .smp-preview-option {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

body.processing .smp-gallery-thumb {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

body.processing .smp-btn-primary {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

body.processing .smp-gallery-thumb::after,
body.processing .smp-preview-option::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* ===== Purchase Panel Redesign ===== */

/* Panel Title */
.smp-panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: center;
}

/* Free Preview Section */
.smp-preview-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.smp-preview-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 600;
}

.smp-preview-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.smp-preview-icon {
    font-size: 1.25rem;
}

.smp-preview-format {
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
}

/* Preview Info Section */
.smp-preview-info {
    margin-bottom: 1.5rem;
}

.smp-info-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--info-light);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    color: var(--text-primary);
}

.smp-info-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
}

.smp-info-text {
    line-height: 1.5;
}

/* Purchase Card */
.smp-purchase-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

/* Options Section */
.smp-options-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.smp-option-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.smp-option-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.smp-option-label {
    display: block;
    padding: 1rem;
    cursor: pointer;
}

.smp-option-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.smp-option-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.smp-option-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.smp-option-icon {
    font-size: 1.25rem;
}

.smp-option-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.smp-option-price {
    font-weight: 700;
    color: var(--primary-color);
}

/* Checkbox checked state */
.smp-option-checkbox:checked ~ .smp-option-content {
    position: relative;
}

.smp-option-checkbox:checked ~ .smp-option-content::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.smp-option-item.smp-option-selected,
.smp-option-checkbox:checked ~ .smp-option-content .smp-option-header {
    color: var(--primary-color);
}

/* Enhanced selection state */
.smp-option-checkbox:checked + .smp-option-content {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.1) 0%, transparent 100%);
}

.smp-option-checkbox:checked ~ .smp-option-content .smp-option-icon {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* JPG option - always selected */
.smp-option-jpg {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, var(--bg-secondary) 100%);
    border-color: var(--accent-color);
}

.smp-option-jpg .smp-option-content {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.1) 0%, transparent 100%);
}

.smp-option-jpg .smp-option-content::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Vector option */
.smp-option-vector {
    border-color: var(--primary-color);
}

.smp-option-included {
    padding: 0.25rem 0.75rem;
    background: var(--accent-color);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* Physical option special styling */
.smp-option-physical {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, var(--bg-secondary) 100%);
}

/* Application Method */
.smp-application-method {
    margin-top: 0.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.smp-method-label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.smp-method-options {
    display: flex;
    gap: 0.75rem;
}

.smp-method-option {
    flex: 1;
    position: relative;
}

.smp-method-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.smp-method-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.smp-method-option input[type="radio"]:checked + .smp-method-box {
    border-color: var(--primary-color);
    background: var(--primary-lightest);
}

.smp-method-icon {
    font-size: 1.5rem;
}

.smp-method-name {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Price Summary */
.smp-price-summary {
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-lightest) 0%, var(--bg-secondary) 100%);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.smp-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.smp-price-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-top: 2px solid var(--border-color);
    margin-top: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.smp-price-total .smp-price-value {
    color: var(--primary-color);
}

/* Action Buttons */
.smp-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.smp-btn-purchase, .smp-btn-ar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.smp-btn-purchase {
    background: var(--gradient-primary);
    color: white;
}

.smp-btn-purchase:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.smp-btn-ar {
    background: var(--gradient-accent);
    color: white;
}

.smp-btn-ar:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.smp-btn-icon {
    font-size: 1.25rem;
}

/* Tooltips */
.smp-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.smp-tooltip.inline {
    margin-left: 0.5rem;
}

.smp-tooltip-icon {
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: help;
    line-height: 1;
}

.smp-tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    padding: 0.75rem;
    background: var(--gray-900);
    color: white;
    font-size: 0.875rem;
    line-height: 1.4;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    pointer-events: none;
    z-index: 1000;
    margin-bottom: 0.5rem;
}

.smp-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--gray-900);
}

.smp-tooltip:hover .smp-tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* Button Groups */
.smp-button-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.smp-button-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
}

/* Dark Theme Adjustments */
[data-theme="dark"] #panel-4 {
    color: white;
}

[data-theme="dark"] #panel-4 * {
    color: white;
}

[data-theme="dark"] .smp-panel-title {
    color: white;
}

[data-theme="dark"] .smp-preview-section {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(100, 116, 139, 0.3);
}

[data-theme="dark"] .smp-preview-btn {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(100, 116, 139, 0.5);
    color: white;
}

[data-theme="dark"] .smp-preview-btn:hover {
    background: rgba(30, 41, 59, 1);
    border-color: var(--primary-color);
}

[data-theme="dark"] .smp-preview-format {
    background: rgba(14, 165, 233, 0.2);
    color: white;
}

[data-theme="dark"] .smp-info-box {
    background: rgba(14, 165, 233, 0.15);
    border-color: rgba(14, 165, 233, 0.5);
    color: white;
}

[data-theme="dark"] .smp-info-text {
    color: white;
}

[data-theme="dark"] .smp-purchase-card {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(100, 116, 139, 0.3);
}

[data-theme="dark"] .smp-option-item {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(100, 116, 139, 0.3);
}

[data-theme="dark"] .smp-option-item:hover {
    background: rgba(30, 41, 59, 0.8);
}

[data-theme="dark"] .smp-option-title {
    color: white;
}

[data-theme="dark"] .smp-option-price {
    color: var(--primary-color);
}

[data-theme="dark"] .smp-preview-text {
    color: white;
}

[data-theme="dark"] .smp-preview-icon {
    color: white;
}

[data-theme="dark"] .smp-option-physical {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(30, 41, 59, 0.5) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .smp-application-method {
    background: rgba(15, 23, 42, 0.5);
}

[data-theme="dark"] .smp-method-label {
    color: var(--gray-400);
}

[data-theme="dark"] .smp-method-box {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(100, 116, 139, 0.3);
    color: var(--gray-200);
}

[data-theme="dark"] .smp-method-option input[type="radio"]:checked + .smp-method-box {
    background: rgba(14, 165, 233, 0.2);
    border-color: var(--primary-color);
}

[data-theme="dark"] .smp-price-summary {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15) 0%, rgba(30, 41, 59, 0.5) 100%);
}

[data-theme="dark"] .smp-price-label {
    color: var(--gray-300);
}

[data-theme="dark"] .smp-price-value {
    color: var(--gray-100);
}

[data-theme="dark"] .smp-price-total {
    border-top-color: rgba(100, 116, 139, 0.3);
}

[data-theme="dark"] .smp-price-total .smp-price-value {
    color: var(--primary-color);
}

[data-theme="dark"] .smp-btn-purchase {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

[data-theme="dark"] .smp-btn-purchase:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}

[data-theme="dark"] .smp-btn-ar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

[data-theme="dark"] .smp-btn-ar:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

[data-theme="dark"] .smp-tooltip-icon {
    color: var(--gray-500);
}

[data-theme="dark"] .smp-tooltip-content {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

[data-theme="dark"] .smp-tooltip-content::after {
    border-top-color: rgba(15, 23, 42, 0.95);
}

[data-theme="dark"] .smp-button-description {
    color: rgba(255, 255, 255, 0.7);
}

/* Dark theme for enhanced selections */
[data-theme="dark"] .smp-option-checkbox:checked + .smp-option-content {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.2) 0%, transparent 100%);
}

[data-theme="dark"] .smp-option-digital {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2) 0%, rgba(30, 41, 59, 0.5) 100%);
    border-color: var(--primary-color);
}

[data-theme="dark"] .smp-option-digital .smp-option-content {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.2) 0%, transparent 100%);
}

[data-theme="dark"] .smp-option-included {
    background: var(--primary-color);
    color: white;
}
