/* --- CONTEXTE THEME CSS DYNAMIQUE (2026 PREMIUM) --- */
:root {
    --bg-body: #f6f8fc;
    --bg-panel: #ffffff;
    --bg-hover: #f1f3f4;
    --bg-active: #e8f0fe;
    --text-title: #202124;
    --text-body: #5f6368;
    --text-light: #80868b;
    --border-color: #dadce0;
    --accent: #1a73e8;
    --accent-hover: #1557b0;
    --sidebar-width: 256px;
    --shadow-panel: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-card: 0 1px 3px 0 rgba(60,64,67,0.3);
}

body.dark-mode {
    --bg-body: #1f1f1f;
    --bg-panel: #111111;
    --bg-hover: #2d2d2d;
    --bg-active: #004b87;
    --text-title: #e3e3e3;
    --text-body: #c7c7c7;
    --text-light: #8e8e8e;
    --border-color: #444746;
    --accent: #a8c7fa;
    --accent-hover: #7cacf8;
    --shadow-panel: 0 1px 3px 0 rgba(0,0,0,0.5);
    --shadow-card: 0 1px 4px 0 rgba(0,0,0,0.6);
}

/* --- FONDATIONS --- */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-title);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- BARRE DE RECHERCHE ET LOGO (HEADER) --- */
header {
    height: 64px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mail-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-title);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.mail-logo span { color: var(--accent); }

.search-container {
    flex: 1;
    max-width: 720px;
    margin: 0 40px;
    position: relative;
}

.search-input {
    width: 100%;
    height: 48px;
    background-color: var(--bg-body);
    border: 1px solid transparent;
    border-radius: 24px;
    padding: 0 20px 0 50px;
    box-sizing: border-box;
    outline: none;
    font-size: 16px;
    color: var(--text-title);
    transition: all 0.2s ease;
}

.search-input:focus {
    background-color: var(--bg-panel);
    border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    fill: var(--text-light);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-icon {
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    color: var(--text-body);
}

.header-icon:hover {
    background-color: var(--bg-hover);
}

.header-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--border-color);
    color: var(--text-title);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- LAYOUT CENTRAL --- */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* --- SIDEBAR --- */
aside {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    justify-content: space-between;
}

.compose-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #1557b0 100%);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.compose-btn:hover {
    box-shadow: 0 4px 8px rgba(26,115,232,0.3);
    transform: translateY(-1px);
}

.compose-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-body);
    transition: background-color 0.2s, color 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-hover);
}

.nav-item.active {
    background-color: var(--bg-active);
    color: var(--accent);
    font-weight: 700;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* --- COMPLIANCE FOOTER --- */
.compliance-footer {
    font-size: 10px;
    color: var(--text-light);
    line-height: 1.4;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
    text-align: justify;
}

/* --- MAIN VIEW (LISTE OU DETAILS) --- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    overflow: hidden;
    position: relative;
}

.list-toolbar {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    gap: 15px;
}

.mail-list-container {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-panel);
}

.empty-inbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-light);
    text-align: center;
    padding: 40px;
}
.empty-inbox-icon { font-size: 48px; margin-bottom: 15px; }

/* --- ELEMENT E-MAIL DE LA LISTE --- */
.mail-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.15s ease;
    font-size: 14px;
    position: relative;
    background-color: var(--bg-panel);
    color: var(--text-body);
}

.mail-row:hover {
    background-color: var(--bg-hover);
    box-shadow: inset 1px 0 0 var(--accent);
}

.mail-row.unread {
    font-weight: 700;
    color: var(--text-title);
}

.mail-star-container {
    margin-right: 15px;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.mail-star-container:hover {
    color: #fbbc05;
}

.mail-star-container.starred {
    color: #fbbc05;
}

.mail-star-container svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.mail-sender {
    width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 20px;
}

.mail-content-summary {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 20px;
    display: flex;
    gap: 10px;
}

.mail-subject {
    color: var(--text-title);
}

.mail-snippet {
    color: var(--text-light);
    font-weight: 400;
}

.mail-date {
    width: 80px;
    text-align: right;
    font-size: 12px;
    color: var(--text-light);
}

.mail-paperclip {
    margin-left: auto;
    margin-right: 10px;
    color: var(--text-light);
    display: flex;
    align-items: center;
}
.mail-paperclip svg { width: 14px; height: 14px; fill: currentColor; }

/* --- DETAILS D'UN EMAIL --- */
.mail-detail-container {
    display: none;
    flex: 1;
    flex-direction: column;
    background-color: var(--bg-panel);
    overflow-y: auto;
    padding: 30px;
    box-sizing: border-box;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.detail-back-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--accent);
    font-size: 14px;
}

.detail-back-btn svg { width: 16px; height: 16px; fill: currentColor; }

.detail-subject {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-title);
    margin: 0 0 15px 0;
    word-break: break-word;
}

.detail-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    font-size: 14px;
}

.meta-sender-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.meta-name { font-weight: 700; color: var(--text-title); }

/* Badges de rôles premium */
.role-badge {
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}
.role-admin { background-color: #fce8e6; color: #c5221f; }
.role-dev { background-color: #e6f4ea; color: #137333; }
.role-official { background-color: #e8f0fe; color: #1a73e8; }

.meta-emails { font-size: 12px; color: var(--text-light); }
.detail-time { font-size: 12px; color: var(--text-light); }

/* Styles du volet déroulant technique */
.technical-headers-disclosure {
    margin-top: 10px;
    font-size: 12px;
}
.technical-headers-disclosure summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    outline: none;
    user-select: none;
}
.headers-content {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 15px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: monospace;
    color: var(--text-body);
}

.detail-body {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-title);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 40px;
}

.detail-attachment-box {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    max-width: 400px;
    margin-bottom: 30px;
    background-color: var(--bg-body);
}

.attachment-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-title);
}

.attachment-image-preview {
    max-width: 100%;
    max-height: 250px;
    border-radius: 6px;
    object-fit: contain;
    display: block;
    margin-bottom: 10px;
}

.attachment-download-link {
    font-size: 12px;
    color: var(--accent);
    text-decoration: underline;
    font-weight: 600;
}

/* --- COMPOSER DRAWER --- */
.composer-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    right: 50px;
    width: 680px;
    height: 580px;
    background-color: var(--bg-panel);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    border: 1px solid var(--border-color);
    z-index: 1000;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s cubic-bezier(0, 0, 0.2, 1), height 0.2s cubic-bezier(0, 0, 0.2, 1);
    animation: slideUpComposer 0.25s cubic-bezier(0, 0, 0.2, 1);
}

.composer-drawer.fullscreen {
    width: calc(100% - 100px) !important;
    height: calc(100% - 40px) !important;
    right: 50px !important;
    border-radius: 12px 12px 0 0 !important;
}

.composer-drawer.fullscreen .composer-editor-content {
    max-height: calc(100vh - 300px) !important;
    min-height: calc(100vh - 400px) !important;
}

.composer-drawer.fullscreen .composer-textarea {
    flex: 1 !important;
}

@keyframes slideUpComposer {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.composer-header {
    background-color: #202124;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
}

.composer-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.composer-close:hover { opacity: 1; }

.composer-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
    box-sizing: border-box;
    background-color: var(--bg-panel);
    overflow: hidden; /* Critical for inner scrolling */
}

.composer-field {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 0;
    font-size: 14px;
}

.composer-field label {
    width: 50px;
    color: var(--text-light);
    font-weight: 500;
}

.composer-field input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-title);
    font-size: 14px;
}

.composer-textarea {
    flex: 1;
    border: none;
    resize: none;
    outline: none;
    padding: 15px 0;
    font-family: inherit;
    font-size: 14px;
    background: transparent;
    color: var(--text-title);
}

.composer-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-panel);
}

.composer-left-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mail-send-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.mail-send-btn:hover { background-color: var(--accent-hover); }

.attachment-btn-label {
    cursor: pointer;
    color: var(--text-body);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background-color 0.2s;
}
.attachment-btn-label:hover { background-color: var(--bg-hover); }
.attachment-btn-label svg { width: 20px; height: 20px; fill: currentColor; }

.attachment-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 12px;
    max-width: 220px;
}
.attachment-indicator span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    color: var(--text-body);
}
.attachment-remove {
    cursor: pointer;
    color: #d93025;
    font-weight: bold;
}

/* --- LOGIN OVERLAY --- */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-body);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.login-card {
    background-color: var(--bg-panel);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-color);
    font-family: inherit;
}

.login-logo {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-title);
}
.login-logo span { color: var(--accent); }

.login-desc {
    color: var(--text-body);
    font-size: 14px;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* --- SETTINGS MODAL --- */
.settings-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.settings-card {
    background-color: var(--bg-panel);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 450px;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.settings-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-title);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    text-align: center;
}

.settings-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.settings-row label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
}

.settings-value {
    font-size: 15px;
    color: var(--text-title);
    font-weight: 600;
}

.settings-select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: inherit;
    font-size: 14px;
    outline: none;
}

.settings-btn-logout {
    width: 100%;
    padding: 12px;
    background-color: #d93025;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    margin-top: 15px;
    margin-bottom: 10px;
    transition: background-color 0.2s;
}
.settings-btn-logout:hover { background-color: #b01b16; }

.settings-btn-clear {
    width: 100%;
    padding: 10px;
    background-color: #e8eaed;
    color: #3c4043;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background-color 0.2s;
}
body.dark-mode .settings-btn-clear {
    background-color: #303134;
    color: #e3e3e3;
}
.settings-btn-clear:hover { background-color: var(--bg-hover); }

.settings-btn-close {
    width: 100%;
    padding: 10px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.settings-btn-close:hover { background-color: var(--accent-hover); }

/* --- LOADING BAR --- */
#mail-loading-bar {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    background-color: var(--accent);
    width: 0%;
    z-index: 3000;
    transition: width 0.3s ease, opacity 0.3s ease;
}

#custom-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #323232;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.2);
    z-index: 9999;
    display: none;
    animation: fadeInToast 0.2s ease;
}

@keyframes fadeInToast {
    from { transform: translate(-50%, 10px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* --- HTML RICH TEXT EDITOR STYLES --- */
.composer-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}

.composer-editor-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-body);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.composer-editor-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--accent);
}

.composer-editor-btn.active {
    background-color: rgba(26, 115, 232, 0.15);
    color: var(--accent);
}

.composer-editor-select, .composer-editor-color {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    height: 28px;
    font-size: 12px;
    color: var(--text-body);
    outline: none;
    padding: 0 4px;
    cursor: pointer;
}

.composer-editor-color {
    width: 32px;
    padding: 0;
    border: none;
}

.composer-editor-content {
    flex: 1;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 12px;
    overflow-y: auto;
    background-color: var(--bg-panel);
    color: var(--text-title);
    font-size: 14px;
    outline: none;
    min-height: 180px;
    max-height: 240px;
    box-sizing: border-box;
}

.composer-editor-content:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.composer-editor-content iframe {
    max-width: 100%;
}

.composer-editor-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 8px 0;
}

.composer-editor-content .editor-btn-element {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--accent);
    color: #ffffff !important;
    text-decoration: none;
    border-radius: 20px;
    font-weight: bold;
    margin: 10px 0;
    text-align: center;
}

/* --- SANDBOX EDITOR LAYOUT --- */
.composer-sandbox-container {
    transition: all 0.2s ease;
}

.composer-sandbox-sidebar .sandbox-panel {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer-sandbox-sidebar .sandbox-panel[open] {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(26,115,232,0.1);
}

.composer-sandbox-sidebar .sandbox-panel summary {
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-title);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.composer-sandbox-sidebar .sandbox-panel summary::-webkit-details-marker {
    display: none;
}

.composer-sandbox-sidebar .sandbox-panel summary::after {
    content: "▼";
    font-size: 8px;
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.composer-sandbox-sidebar .sandbox-panel[open] summary::after {
    transform: rotate(-180deg);
    color: var(--accent);
}

.composer-sandbox-sidebar input,
.composer-sandbox-sidebar select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-panel);
    color: var(--text-title);
    font-family: inherit;
    font-size: 11px;
    box-sizing: border-box;
    outline: none;
}

.composer-sandbox-sidebar input:focus,
.composer-sandbox-sidebar select:focus {
    border-color: var(--accent);
}

.composer-sandbox-sidebar label {
    font-size: 10px;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 2px;
}

/* Make sure the canvas/sandbox workspace adapts inside the drawer */
.composer-drawer.fullscreen .composer-sandbox-container {
    height: calc(100vh - 200px) !important;
}

.composer-drawer.fullscreen .composer-editor-content {
    min-height: calc(100vh - 280px) !important;
}

/* --- CANVAS SANDBOX DYNAMIC WRAPPER --- */
.sandbox-element-wrapper {
    position: absolute !important;
    padding: 10px 14px 10px 22px; /* Extra padding on the left for drag handles */
    border: 1px dashed #cbd5e0;
    border-radius: 6px;
    background-color: transparent;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.sandbox-element-wrapper:hover,
.sandbox-element-wrapper.active {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(26,115,232,0.15);
    background-color: rgba(255, 255, 255, 0.95);
}

/* Drag handle indicator */
.sandbox-element-wrapper::before {
    content: "⋮⋮";
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #a0aec0;
    font-weight: bold;
    cursor: move;
}

.sandbox-element-wrapper .sandbox-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background-color: #e53e3e;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 9px;
    font-weight: bold;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 10;
}

.sandbox-element-wrapper:hover .sandbox-delete-btn,
.sandbox-element-wrapper.active .sandbox-delete-btn {
    display: flex;
}

/* Layer controls wrapper (Bring to Front / Send to Back) */
.sandbox-layer-controls {
    position: absolute;
    bottom: -22px;
    left: 0;
    display: none;
    gap: 4px;
    z-index: 10;
}

.sandbox-element-wrapper.active .sandbox-layer-controls {
    display: flex;
}

.sandbox-layer-btn {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-title);
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}

.sandbox-layer-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent);
}

/* Resize Handles */
.sandbox-resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: var(--accent);
    border: 1px solid #ffffff;
    border-radius: 50%;
    z-index: 11;
    display: none;
}

.sandbox-element-wrapper.active .sandbox-resize-handle {
    display: block;
}

/* Position resize handles precisely */
.sandbox-resize-handle.nw { top: -4px; left: -4px; cursor: nwse-resize; }
.sandbox-resize-handle.ne { top: -4px; right: -4px; cursor: nesw-resize; }
.sandbox-resize-handle.se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.sandbox-resize-handle.sw { bottom: -4px; left: -4px; cursor: nesw-resize; }

/* Custom styles for inner sandbox elements */
.sandbox-textbox-el {
    outline: none;
    border: 1px solid transparent;
    padding: 4px;
    border-radius: 4px;
    word-break: break-word;
    user-select: text; /* Allow text highlight in edit state */
    min-width: 100px;
    min-height: 20px;
    display: inline-block;
}

.sandbox-textbox-el:focus {
    border-color: var(--accent);
    background-color: rgba(255, 255, 255, 1);
}