/* --- ROOT VARIABLES --- */
:root {
    --bg-main: #0a0a0a;
    --bg-sidebar: #1a1a1a;
    --accent-purple: #a044ff;
    --accent-hover: #b366ff;
    --accent-dark: #4a148c;
    --text-light: #e0e0e0;
    --border-color: #333;
    --canvas-shadow: 0 0 40px rgba(0,0,0,0.6);
}

/* --- CORE LAYOUT --- */
body {
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-light);
    font-family: 'Inter', sans-serif;
}

/* --- SIDEBAR & NAVIGATION --- */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100vh;
}

/* Slim Custom Scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: var(--bg-sidebar); }
.sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--accent-purple); }

.sidebar .p-3 { padding: 1rem !important; }
.uppercase { text-transform: uppercase; letter-spacing: 0.8px; font-size: 0.65rem; }
.title-purple { color: var(--accent-purple); font-weight: 800; }

/* --- ACCORDION UI --- */
.accordion-item {
    background-color: transparent !important;
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.accordion-button {
    background-color: transparent !important;
    color: var(--text-light) !important;
    font-size: 0.8rem !important;
    padding: 12px 15px !important;
    box-shadow: none !important;
}

.accordion-button:not(.collapsed) {
    background-color: rgba(160, 68, 255, 0.1) !important;
    color: var(--accent-purple) !important;
}

.accordion-button::after { filter: invert(1); transform: scale(0.7); }

.accordion-body {
    padding: 10px 15px 15px 15px !important;
    background-color: rgba(0, 0, 0, 0.2);
}

/* --- WORKSPACE & CANVAS --- */
.workspace {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(circle, #1a1a1a 0%, #0a0a0a 100%);
}

#pages-container { display: flex; flex-direction: column; gap: 60px; }

.page-wrapper { position: relative; }

.canvas-white {
    width: 210mm;
    height: 297mm;
    background: white;
    position: relative;
    box-shadow: var(--canvas-shadow);
}

/* --- CANVAS ELEMENTS --- */
.element { position: absolute; cursor: move; box-sizing: border-box; }
.element.selected { outline: 2px solid var(--accent-purple); }

/* Control Visibility */
.element:hover .delete-btn, 
.element:hover .resizer,
.element.selected .delete-btn, 
.element.selected .resizer {
    display: flex !important;
}

/* --- CONTENT TYPES --- */
.text-content { 
    width: 100%; height: 100%; 
    color: black; outline: none; 
    padding: 5px; word-break: break-all; 
    overflow: hidden; 
}

/* Image Stretch Logic */
.image-box img { 
    width: 100% !important; 
    height: 100% !important; 
    object-fit: fill !important; 
    display: block;
    pointer-events: none; 
}

.table-element table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
.table-element td { border: 1px solid #ccc; color: black; text-align: center; padding: 2px; font-size: 0.9rem; }

/* --- INTERACTIVE CONTROLS --- */
.resizer {
    position: absolute;
    width: 12px; height: 12px;
    background: var(--accent-purple);
    border: 2px solid white;
    right: -6px; bottom: -6px;
    cursor: nwse-resize;
    display: none;
    border-radius: 50%;
}

.delete-btn {
    position: absolute;
    top: -32px; right: 0;
    background-color: var(--accent-purple);
    color: white; border: none;
    border-radius: 50%;
    width: 26px; height: 26px;
    display: none; align-items: center; justify-content: center;
    cursor: pointer; z-index: 9999;
}

.delete-page-btn {
    position: absolute;
    top: -35px; right: 0;
    background: #ff4d4d; color: white;
    border: none; padding: 4px 10px;
    border-radius: 4px; font-size: 10px;
    cursor: pointer; z-index: 10;
}

/* Upload Button inside AI Image Box */
.upload-trigger-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--accent-purple);
    color: white; border: none;
    padding: 10px 20px; border-radius: 5px;
    cursor: pointer; font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.upload-trigger-btn:hover { background-color: var(--accent-dark); }

/* --- BUTTONS & INPUTS --- */
.btn-purple-action { 
    background: var(--accent-purple); 
    color: white; border: none; 
    font-weight: bold; transition: 0.2s; 
}
.btn-purple-action:hover { background: var(--accent-hover); }
.btn-purple-action:disabled { background: #444; cursor: not-allowed; }

.btn-outline-purple { 
    border: 1px solid var(--accent-purple); 
    color: var(--accent-purple); 
    font-size: 0.75rem; font-weight: 600;
}
.btn-outline-purple:hover, .btn-check:checked + .btn-outline-purple { 
    background: var(--accent-purple); color: white !important; 
}

.form-select-sm, .form-control-sm {
    background-color: #000 !important;
    border-color: #444 !important;
    color: white !important;
    font-size: 0.75rem !important;
}

/* --- ALIGNMENT GUIDES --- */
.guide-line {
    position: absolute;
    background-color: var(--accent-purple);
    display: none; z-index: 9998;
    pointer-events: none;
}
.guide-x { width: 1px; height: 100%; top: 0; }
.guide-y { height: 1px; width: 100%; left: 0; }