:root {
    --bg-gradient-start: #fdfbfb;
    --bg-gradient-end: #ebedee;
    --primary-color: #ff6b6b;
    --text-color: #2d3436;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --phone-bg: #ffe4e1;
    --phone-shadow: -20px 20px 60px rgba(0, 0, 0, 0.15), inset -5px -5px 15px rgba(255, 255, 255, 0.8), inset 5px 5px 10px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-color);
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    min-height: 100vh;
    overflow: hidden;
    user-select: none; /* Prevent text selection while dragging */
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 380px;
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.sidebar-header h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

.color-pickers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.color-picker-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.color-picker-container label {
    font-weight: 600;
    font-size: 1rem;
}

input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.tools-container {
    margin-bottom: 1rem;
}

.tools-container h3, .assets-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 600;
}

.tool-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.tool-btn {
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color);
    font-weight: 500;
    text-align: left;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.6);
}

.tool-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
}

.assets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    flex-grow: 1;
    align-content: start;
    overflow-y: auto;
    padding-bottom: 2rem;
}

/* Custom scrollbar for assets grid */
.assets-grid::-webkit-scrollbar {
    width: 6px;
}
.assets-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.sticker-source {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 0.5rem;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.8);
    touch-action: none;
}

.sticker-source:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
}

.sticker-source:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
}

.action-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-color);
    font-family: inherit;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.action-btn:hover {
    background: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(1px);
}

/* Workspace Styling */
.workspace {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.phone-wrapper {
    perspective: 1000px;
}

.phone-case {
    width: 340px;
    height: 700px;
    background: var(--phone-bg);
    border-radius: 50px;
    box-shadow: var(--phone-shadow);
    position: relative;
    overflow: hidden;
    /* Subtle glossy gradient */
    background-image: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.02) 100%);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.phone-case:hover {
    transform: rotateY(5deg) rotateX(2deg);
}

/* Paint Canvas */
#paint-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* Default off so we can drag stickers initially */
    touch-action: none;
}

/* Phone details */
.camera-bump {
    position: absolute;
    top: 25px;
    left: 25px;
    width: 100px;
    height: 110px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 25px;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.05), inset -2px -2px 5px rgba(255,255,255,0.5), 2px 2px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 5;
}

.lens {
    width: 40px;
    height: 40px;
    background: #111;
    border-radius: 50%;
    position: absolute;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8), inset 2px 2px 2px rgba(255,255,255,0.2), 0 0 0 2px #333, 0 0 0 4px rgba(255,255,255,0.1);
}

.lens-top {
    top: 10px;
    left: 10px;
}

.lens-bottom {
    bottom: 10px;
    left: 10px;
}
.flash {
    width: 15px;
    height: 15px;
    background: #fdfdfd;
    border-radius: 50%;
    margin-top: 10px;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.8), inset 0 0 5px #ccc;
}

/* --- Animations --- */
@keyframes dragPulse {
    0% { transform: scale(1); filter: brightness(1) drop-shadow(0 15px 35px rgba(0,0,0,0.2)); }
    50% { transform: scale(1.05) rotate(2deg); filter: brightness(1.1) drop-shadow(0 25px 45px rgba(0,0,0,0.3)); }
    100% { transform: scale(1); filter: brightness(1) drop-shadow(0 15px 35px rgba(0,0,0,0.2)); }
}

@keyframes dropPop {
    0% { transform: scale(1.2); filter: drop-shadow(0 20px 40px rgba(0,0,0,0.4)); opacity: 0.8; }
    50% { transform: scale(0.95); filter: drop-shadow(0 5px 15px rgba(0,0,0,0.1)); opacity: 1; }
    80% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Placed Stickers */
.sticker-placed {
    position: absolute;
    cursor: grab;
    z-index: 20;
    transition: transform 0.1s ease-out;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.15));
}

.sticker-placed-anim {
    animation: dropPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.sticker-placed.dragging {
    cursor: grabbing;
    filter: drop-shadow(5px 10px 15px rgba(0,0,0,0.25));
    z-index: 100 !important;
}

/* Floating copy while dragging from sidebar */
.sticker-clone {
    position: fixed;
    pointer-events: none; /* Let mouse events pass through to drop zones */
    width: 100px;
    z-index: 1000;
    filter: drop-shadow(5px 10px 15px rgba(0,0,0,0.2));
    transform: translate(-50%, -50%) scale(1.1);
    transition: transform 0.1s;
}

/* Responsive */
@media (max-width: 900px) {
    #app {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        padding: 1.5rem;
        flex-shrink: 0;
    }
    .assets-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 1rem;
        padding-bottom: 1rem;
    }
    .sticker-source {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }
    .phone-case {
        transform: scale(0.8);
    }
    .phone-case:hover {
        transform: scale(0.8) rotateY(0) rotateX(0);
    }
}
