/* --- PROFESSIONAL DARK THEME --- */
:root {
    --bg-body: #09090b;
    --bg-sidebar: #121214;
    --bg-panel: #1c1c1f;
    --input-bg: #27272a;
    --border: #3f3f46;
    --accent: #d4af37; /* Gold */
    --accent-hover: #b59325;
    --text-main: #e4e4e7;
    --text-muted: #a1a1aa;
}

body { margin: 0; font-family: 'Inter', sans-serif; background: var(--bg-body); color: var(--text-main); height: 100vh; overflow: hidden; user-select: none; }
#app-layout { display: grid; grid-template-columns: 380px 1fr; height: 100%; }
#sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; z-index: 20; }

.header { padding: 15px; border-bottom: 1px solid var(--border); background: #000; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.header h3 { margin: 0; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.header-btns { display: flex; gap: 5px; }

.toolbar { padding: 10px 15px; display: flex; gap: 8px; border-bottom: 1px solid var(--border); background: var(--bg-panel); flex-shrink: 0; }
.btn-tool { padding: 8px 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text-main); cursor: pointer; font-size: 0.8rem; flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; transition: 0.2s; }
.btn-tool:hover { background: #333; border-color: #666; }
.btn-tool:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: black; border: none; font-weight: bold; }
.btn-primary:hover { background: var(--accent-hover); }

#view-edit { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#properties-panel { flex: 1; overflow-y: auto; padding: 15px; padding-bottom: 50px; scrollbar-width: thin; scrollbar-color: #333 #121214; }
#properties-panel::-webkit-scrollbar { width: 8px; }
#properties-panel::-webkit-scrollbar-track { background: #121214; }
#properties-panel::-webkit-scrollbar-thumb { background-color: #333; border-radius: 4px; }

.control-section { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; padding: 15px; margin-bottom: 20px; }
.section-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--accent); }

.form-group { margin-bottom: 12px; }
label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 5px; }
input[type="text"], input[type="number"], select, textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--border); color: white; padding: 8px; border-radius: 4px; font-size: 0.85rem; box-sizing: border-box; outline: none; font-family: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-wrapper { display: flex; align-items: center; gap: 10px; background: var(--input-bg); border: 1px solid var(--border); padding: 5px; border-radius: 4px; }
input[type="color"] { -webkit-appearance: none; border: none; width: 30px; height: 30px; padding: 0; background: none; cursor: pointer; }

.layer-list { list-style: none; padding: 0; margin: 0; max-height: 150px; overflow-y: auto; }
.layer-item { padding: 8px 10px; font-size: 0.8rem; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.layer-item.active { background: var(--accent); color: black; font-weight: 600; }

#canvas-area { background: #000; display: flex; justify-content: center; align-items: flex-start; position: relative; }
iframe { width: 100%; height: 100%; border: none; background: white; }
.hidden { display: none !important; }

#btn-preview-float { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100; background: rgba(40, 40, 45, 0.8); backdrop-filter: blur(5px); border: 1px solid var(--border); color: var(--text-main); padding: 8px 24px; border-radius: 30px; cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; transition: 0.2s; }
#btn-preview-float:hover { background: var(--accent); color: black; font-weight: 600; transform: translateX(-50%) scale(1.05); }

#preview-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.modal-content { width: 90%; height: 90%; background: #fff; position: relative; border-radius: 4px; overflow: hidden; display: flex; flex-direction: column; }
.modal-header { padding: 10px 20px; background: #121214; color: white; display: flex; justify-content: space-between; align-items: center; }
#preview-iframe-modal { width: 100%; flex: 1; border: none; background: white; }
#btn-close-modal { background: #ef4444; color: white; border: none; padding: 6px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; }

.uploading { opacity: 0.5; pointer-events: none; cursor: wait !important; }

/* --- MOBILE RESPONSIVENESS (50/50 Split) --- */
@media (max-width: 768px) {
    #app-layout {
        display: flex;
        flex-direction: column; /* Use column-reverse to put Canvas Top / Editor Bottom */
    }
    #sidebar {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    #canvas-area {
        width: 100%;
        height: 50vh;
    }
    #properties-panel {
        padding-bottom: 20px; 
    }
}