:root {
    /* Dokoyo Theme Alignment (Softer Palette) */
    --bg-color: #f5f5f7;
    --panel-bg: #ffffff;
    --text-main: #1c1c1e;
    --text-muted: #777777;
    --primary: #1c1c1e;
    --primary-text: #ffffff;
    --primary-hover: #333333;
    --secondary: #e5e5e5;
    --success: #10b981;
    --success-hover: #059669;
    --border: #e0e0e0;
    --ai-gradient: linear-gradient(135deg, #1c1c1e, #555555);
    --modal-overlay: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --panel-bg: #1c1c1e;
    --text-main: #f5f5f7;
    --text-muted: #a1a1aa;
    --primary: #f5f5f7;
    --primary-text: #1c1c1e;
    --primary-hover: #d4d4d8;
    --secondary: #2d2d2d;
    --border: #333333;
    --ai-gradient: linear-gradient(135deg, #333, #111);
    --modal-overlay: rgba(18, 18, 18, 0.85);
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}
.editor-layout {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    justify-content: center;
    min-height: 90vh;
}
.canvas-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
/* ==============================================================
   GLOWING RAINBOW BUTTON & STYLE GALLERY MODAL
============================================================== */
/* Glowing Rainbow Button */
.glowing-rainbow {
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: #111; /* Dark background */
    color: white;
    border: none;
    transition: transform 0.2s ease;
}
.glowing-rainbow::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    background-size: 400%;
    z-index: -1;
    border-radius: 14px;
    animation: rainbow-glow 20s linear infinite;
    opacity: 0.8;
}
.glowing-rainbow::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px; right: 2px; bottom: 2px;
    background: #1a1a1a; /* Inner button color */
    z-index: -1;
    border-radius: 10px;
}
.glowing-rainbow:hover {
    transform: scale(1.02);
}
.glowing-rainbow:hover::before {
    animation: rainbow-glow 5s linear infinite; /* Faster on hover */
    filter: blur(8px);
}
@keyframes rainbow-glow {
    0% { background-position: 0 0; }
    50% { background-position: 400% 0; }
    100% { background-position: 0 0; }
}
/* Style Modal Layout */
.style-modal-content {
    max-width: 800px;
    width: 90%;
    padding: 24px;
}
.style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 8px; /* Scrollbar spacing */
}
.style-card {
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    background: #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
}
.style-card img {
    width: 100%;
    aspect-ratio: 42 / 31;
    object-fit: cover;
    border-bottom: 1px solid #eee;
    -webkit-user-drag: none;
    pointer-events: none; /* Mencegah klik kanan langsung pada gambar */
}
.style-card .style-name {
    padding: 10px 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
}
.style-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}
.style-card.selected {
    border-color: #ff00c8;
    box-shadow: 0 0 0 3px rgba(255, 0, 200, 0.2);
}
/* Preview Box di Sidebar */
.style-preview-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    margin-bottom: 12px;
}
.style-preview-box img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
}
.style-preview-box span {
    font-size: 0.95rem;
    font-weight: 500;
}
.canvas-wrapper {
    position: relative;
    width: 500px;
    height: 500px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    background: #c5c5c5;
    border: none;
}
/* Zakeke Style Layered Preview */
.product-preview-container {
    position: relative;
    width: 500px;
    height: 500px;
    background-color: transparent;
    border-radius: 0;
    overflow: hidden;
    
    /* Security tweaks to prevent saving image */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.design-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    clip-path: polygon(15% 25%, 85% 25%, 80% 75%, 65% 85%, 50% 60%, 35% 85%, 20% 75%);
}
.shadow-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    object-fit: cover;
    mix-blend-mode: multiply;
    pointer-events: none;
}
/* Toolbar Undo Redo di atas Kanvas */
.canvas-toolbar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}
.canvas-toolbar button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--panel-bg);
    backdrop-filter: blur(2px);
    border: 1px solid var(--border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}
.canvas-toolbar button:hover:not(:disabled) {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.canvas-toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.toolbar-btn-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Flip Animation */
@keyframes flipAnimation {
    0% { transform: perspective(1000px) rotateY(0deg); }
    50% { transform: perspective(1000px) rotateY(90deg); opacity: 0.5; }
    100% { transform: perspective(1000px) rotateY(0deg); opacity: 1; }
}
.flip-animate {
    animation: flipAnimation 0.4s ease-in-out;
}
.toolbar-btn-wrapper span {
    font-size: 0.75rem;
    color: var(--text-main);
    font-weight: 600;
    text-shadow: none;
}
.canvas-action-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 10;
}
.action-btn {
    padding: 8px 16px;
    background: var(--panel-bg);
    backdrop-filter: blur(2px);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
}
.action-btn:hover {
    background: var(--secondary);
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.bottom-view-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    z-index: 10;
}
.bottom-view-toggle .view-btn {
    background: var(--panel-bg);
    backdrop-filter: blur(2px);
    border-radius: 20px;
    padding: 8px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    white-space: nowrap;
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
}
.bottom-view-toggle .view-btn.active {
    background: var(--primary);
    color: var(--primary-text);
}
.style-panel {
    width: 240px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.controls-section {
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.control-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}
.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 12px;
    line-height: 1.5;
}
button, .btn-primary, .btn-ai, .btn-success {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
}
.btn-primary:hover { 
    background: var(--primary-hover); 
    transform: translateY(-2px); 
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
.btn-ai {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    margin-top: 12px;
}
.btn-ai:hover:not(:disabled) { 
    background: var(--primary);
    color: white;
}
.btn-ai:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--text-muted);
    color: var(--text-muted);
}
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}
/* Hue Slider (Rainbow) */
.hue-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, 
        #ff0000 0%, #ffff00 17%, #00ff00 33%, 
        #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
    margin-top: 8px;
}
.hue-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ccc;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.hue-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ccc;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
/* Brightness Slider */
.brightness-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #000000 0%, #ff0000 50%, #ffffff 100%);
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
    margin-top: 8px;
    transition: background 0.3s;
}
.brightness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ccc;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.brightness-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid #ccc;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
/* Toggle Front/Back */
.view-toggle-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}
.view-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.2s;
    color: var(--text-main);
}
.view-btn.active {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}
/* Product Selector Vertical */
.product-selector-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.product-selector-vertical .prod-btn {
    padding: 12px 16px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: 0.2s;
    color: var(--text-main);
    text-align: left;
    display: block;
    width: 100%;
}
.product-selector-vertical .prod-btn.active {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}
/* Path Toggle (Manual vs AI) */
.path-toggle-container {
    display: flex;
    background: var(--primary);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}
.path-btn {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-text);
    background: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
}
.path-btn.active {
    background: var(--panel-bg);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.design-path-section {
    animation: fadeIn 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.outline-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--secondary);
    margin-bottom: 20px;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
/* Utilities */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
/* AI Style Selector */
.ai-style-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-style-btn {
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-style-btn:hover {
    border-color: var(--primary);
    background: var(--secondary);
}
.ai-style-btn.active {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}
.generate-btn {
    background: var(--ai-gradient);
    color: white;
    border: none;
    margin-top: 16px;
    font-size: 1rem;
}
.generate-btn:hover {
    box-shadow: 0 8px 15px rgba(28, 28, 28, 0.3);
    transform: translateY(-2px);
}
/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal.hidden {
    display: none;
}
.modal-content {
    width: 90%;
    max-width: 600px;
    background: var(--panel-bg);
    color: var(--text-main);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: var(--text-main);
}
.modal-header button {
    width: auto;
    background: none;
    color: var(--text-main);
    font-size: 2rem;
    padding: 0;
}
textarea {
    width: 100%;
    height: 350px;
    background: var(--secondary);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: none;
    margin-top: 16px;
}

/* Size Buttons */
.size-btn {
    background: var(--panel-bg);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 10px 5px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.size-btn:hover {
    border-color: #999;
}
.size-btn.active {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}
.zoom-controls button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-main);
    transition: 0.2s;
}
.zoom-controls button:hover {
    background: var(--secondary);
    transform: scale(1.05);
}

/* Layers Management */
.layers-container {
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
}
.layer-empty-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 20px 0;
}
.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.layer-item.active {
    border-color: var(--primary);
    background: var(--secondary);
}
.layer-item-name {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.layer-controls {
    display: flex;
    gap: 4px;
}
.layer-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--panel-bg);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: 0.2s;
    padding: 0;
}
.layer-btn:hover {
    background: var(--secondary);
    color: var(--text-main);
}
.layer-btn.delete {
    color: #ef4444;
}
.layer-btn.delete:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #ef4444;
}

/* Theme Toggle Button */
#theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--panel-bg);
    color: var(--text-main);
    border: none;
    border-radius: 24px;
    padding: 6px 14px;
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.2s ease;
    z-index: 1000;
}
#theme-toggle:hover {
    opacity: 0.8;
}

.toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 10001; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast { background: #059669; color: white; padding: 12px 24px; border-radius: 8px; font-size: 0.95rem; font-weight: 500; opacity: 0; animation: fadeinout 3s forwards; box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: auto; }
@keyframes fadeinout { 0% { opacity: 0; transform: translateY(20px); } 10% { opacity: 1; transform: translateY(0); } 90% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-20px); } }
