:root {
    --bg-dark: #333333;
    --bg-darker: #222222;
    --accent-light: rgba(255, 255, 255, 0.1);
    --accent-glow: #f4f4f4;
    --text-main: #ffffff;
    --text-muted: #999999;
    --border-color: rgba(255, 255, 255, 0.15);
    --glass-bg: rgba(70, 70, 70, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --btn-primary: #6247b5;
    --btn-primary-hover: #393185;
    --btn-action: #E51A4B;

    font-family: 'Montserrat', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-darker));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    width: 95vw;
    height: 90vh;
    max-width: 1400px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: rgba(43, 43, 43, 0.4);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 20;
}

/* Scrollbar styles for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-light);
    border-radius: 10px;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.brand-logo {
    max-width: 150px;
    margin-bottom: 1rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #b894ac);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}
.subtitle2 a{
    color: var(--btn-action);
    font-size: 0.95rem;
    text-decoration: none;
}

/* Controls */
.control-groups {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.control-group h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #dddddd;
}

/* Part selectors */
.part-selectors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.part-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.part-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    transform: translateY(-2px);
}

.part-btn.active {
    background: rgba(218, 149, 235, 0.308);
    border-color: var(--accent-glow);
    color: var(--accent-glow);
    box-shadow: 0 0 15px rgba(241, 241, 241, 0.2);
}

/* Color Picker */
.color-picker-container {
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px inset rgba(255, 255, 255, 0.05);
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.hex-input-group {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
    justify-content: center;
}

#hex-input {
    width: 120px;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* File Upload */
.custom-file-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.custom-file-upload:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-glow);
    color: var(--text-main);
}

.custom-file-upload input[type="file"] {
    display: none;
}

/* Button variants */
.action-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.action-btn.outline {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
}

.action-btn.outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

.action-btn.primary {
    background: var(--btn-primary);
    color: white;
    border: none;
    margin-top: 1rem;
}

.action-btn.primary:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-2px);
}

#save-btn {
    margin-top: 1rem;
}

#reset-btn {
    margin-top: 10px;
}

/* Text Input */
.text-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.text-input:focus {
    border-color: var(--accent-glow);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Preview Area */
.preview-area {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    overflow: hidden;
}

.background-effects {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.blur-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 1;
}

.circle-1 {
    width: 400px;
    height: 400px;
    background: rgba(216, 216, 216, 0.15);
    top: 10%;
    left: 20%;
}

.circle-2 {
    width: 500px;
    height: 500px;
    background: rgba(246, 92, 213, 0.15);
    bottom: 5%;
    right: 15%;
}

.logo-preview { 
    width: 120px; 
    height: auto; 
    margin: 20px; 
    filter: grayscale(100%) brightness(200%);
    z-index: -1;
}

.canvas-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* Bottle Architecture */
.bottle-container {
    position: relative;
    width: 400px;
    /* Fallback proportional dimensions */
    height: 700px;
    /* Fallback proportional dimensions */
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 4/7;
    /* This container holds everything that will be screenshotted */
}

/* Placeholder for missing real images */
.bottle-container::before {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    z-index: -1;
    opacity: 0.5;
}

.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.bottle-base {
    z-index: -1;
    object-fit: contain;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Mask layers use CSS masks */
.color-mask {
    z-index: 999;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    /* Removed mix-blend-mode: multiply so color is vividly visible even on dark backgrounds */
    mix-blend-mode: normal;
    opacity: 0.9;
    /* Slight opacity so base details show through */
    pointer-events: none;
}

.color-fill {
    width: 100%;
    height: 100%;
    background-color: transparent;
    transition: background-color 0.1s ease;
}

/* Label specific styles */
.label-mask {
    z-index: 999;
    mix-blend-mode: normal;
    /* Labels are usually opaque over the glass */
}

.label-content {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Adding some 3D perspective to simulate label wrap if no mask is provided */
    transform: perspective(600px) rotateY(0deg);
}

#label-logo {
    width: 60%;
    max-height: 100%;
    object-fit: contain;
    margin-bottom: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#label-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
    color: #ffffff;
    max-width: 80%;
    word-wrap: break-word;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Responsive details */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .bottle-container {
        max-height: 45vh;
    }
}

/* Color Codes Legend (for PNG Export) */
.color-codes-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(15, 23, 42, 0.7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 12px;
    color: white;
    font-size: 0.8rem;
    z-index: 20;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    /* so it doesn't block interaction */
}

.color-codes-legend h4 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #cbd5e1;
    background: none;
    -webkit-text-fill-color: inherit;
}

.color-codes-legend ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.color-codes-legend li {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
    font-family: inherit;
}

.color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-block;
}

/* Lighting Modes and Slider */
.bottle-base {
    transition: filter 0.3s ease;
}

.bottle-base.light-normal {
    filter: none;
}

.bottle-base.light-studio {
    filter: contrast(1.2) brightness(0.8) drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
}

.bottle-base.light-bright {
    filter: contrast(1.1) brightness(1.3) drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
}

.range-slider {
    width: 100%;
    margin-top: 8px;
    accent-color: var(--accent-glow);
    cursor: pointer;
}

/* Utility / Extracted Styles */
.setting-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.setting-label.block-label {
    display: block;
    margin-bottom: 8px;
}

.span-2 {
    grid-column: span 2;
}

.mt-15 {
    margin-top: 15px;
}

.lighting-options {
    grid-template-columns: 1fr 1fr 1fr;
    margin-bottom: 0;
}

.light-btn {
    font-size: 0.75rem;
    padding: 0.5rem;
}

#logo-size-container {
    display: none;
    margin-top: 15px;
}

.d-none {
    display: none;
}