:root {
    /* Vibrant & Harmonious Palette */
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);

    --secondary-color: #10b981;
    /* Emerald 500 */
    --secondary-hover: #059669;
    /* Emerald 600 */

    --accent-color: #f43f5e;
    /* Rose 500 */
    --accent-hover: #e11d48;
    /* Rose 600 */

    --background-color: #f8fafc;
    /* Slate 50 */
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    /* Slate 800 */
    --text-secondary: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    /* Slate 200 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-title h1 {
    font-size: 1.875rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-title p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* User Section */
.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#userProfile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

#userAvatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

#userName {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: #fee2e2;
    color: var(--accent-color);
}

/* Auth Button */
.auth-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: white;
    color: #3c4043;
    border: 1px solid #dadce0;
    padding: 0.6rem 1.25rem;
    border-radius: 24px;
    font-weight: 500;
    font-family: 'Google Sans', 'Roboto', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    font-size: 0.95rem;
}

.auth-btn:hover {
    background-color: #f8f9fa;
    box-shadow: var(--shadow-md);
    color: #202124;
    border-color: #d2e3fc;
}

.auth-btn i {
    font-size: 1.25rem;
    color: #4285f4;
}

/* Main Layout */
.app-layout {
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
    flex: 1;
}

/* Controls Sidebar */
.controls {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    border: 1px solid var(--border-color);
    width: 380px;
    flex-shrink: 0;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Inputs */
input[type="text"],
select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: #f8fafc;
    transition: all 0.2s ease;
    width: 100%;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
    pointer-events: none;
}

.input-icon-wrapper input {
    padding-left: 3rem;
}

/* Upload Buttons */
.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    color: white;
    text-align: center;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.upload-btn.primary {
    background-color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.upload-btn.primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.4);
}

.upload-btn.secondary {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.upload-btn.secondary:hover {
    background-color: #f8fafc;
    border-color: var(--text-secondary);
}

/* Action Buttons */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--text-primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.action-btn:hover {
    background-color: #0f172a;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Reset Button - Override inline styles with !important */
.action-btn.secondary {
    background-color: #fee2e2 !important;
    /* Light Red */
    color: var(--accent-color) !important;
    /* Dark Red Text */
    border: 1px solid #fecaca !important;
    margin-top: 10px;
}

.action-btn.secondary:hover {
    background-color: #fecaca !important;
    color: var(--accent-hover) !important;
}

/* Mode Switch */
.mode-switch-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.mode-switch {
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    display: flex;
    gap: 4px;
    width: 100%;
}

.mode-switch input {
    display: none;
}

.mode-switch label {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mode-switch input:checked+label {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Preview Area */
.preview-area {
    background: #e2e8f0;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    padding: 3rem;
    flex-grow: 1;
    min-height: 700px;
}

.canvas-wrapper {
    box-shadow: var(--shadow-lg);
    background: white;
    line-height: 0;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

#placeholder-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 1.1rem;
    pointer-events: none;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Instructions */
.instructions {
    margin-top: auto;
    background: #f8fafc;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.instructions h3 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.instructions ul {
    padding-left: 1.2rem;
}

.instructions li {
    margin-bottom: 0.4rem;
}

/* Legend Items */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.product {
    background-color: #4f46e5;
}

.dot.name {
    background-color: #ec4899;
}

.dot.code {
    background-color: #10b981;
}

.dot.info {
    background-color: #f59e0b;
}

/* Custom Inputs */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: var(--shadow-sm);
    border: 2px solid white;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--border-color);
    border-radius: 2px;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 100%;
    height: 48px;
    cursor: pointer;
    padding: 0;
    background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .container {
        padding: 1rem;
        gap: 1.5rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .user-section {
        width: 100%;
        justify-content: space-between;
    }

    .app-layout {
        flex-direction: column-reverse;
        gap: 1.5rem;
    }

    .controls {
        width: 100%;
        position: static;
        max-height: none;
    }

    .preview-area {
        width: 100%;
        min-height: 400px;
        padding: 1rem;
    }
}
/* User Overrides */
.upload-btn.primary { color: white !important; }
.upload-btn.primary i { color: white !important; }

/* Drag and Drop Visual Feedback */
.upload-btn.secondary.drag-over { border: 2px dashed var(--primary-color); background-color: #e0e7ff; color: var(--primary-color); }

/* Logo Styling */
.site-logo { height: 50px; width: auto; margin-bottom: 1rem; }
.header-title { display: flex; flex-direction: column; align-items: flex-start; }

/* Canvas Overlay for Drag-to-Save */
.canvas-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; z-index: 10; display: none; cursor: grab; }
.canvas-wrapper { position: relative; }

/* Masking Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.modal-content { background: white; padding: 20px; border-radius: 12px; width: 90%; max-width: 800px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.modal-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; align-items: center; background: #f3f4f6; border-radius: 8px; padding: 10px; }
#maskingCanvas { max-width: 100%; max-height: 60vh; object-fit: contain; cursor: crosshair; }
.modal-footer { margin-top: 15px; display: flex; justify-content: flex-end; gap: 10px; }
.instruction-text { margin-top: 10px; font-size: 0.9rem; color: #6b7280; }
