/* Designer Pro - Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #3b3b3b;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.toolbar {
    background: #3f3f3f;
    padding: 12px 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 2px solid #404040;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
    /* padding-right: 15px; */
    border-right: 1px solid #404040;
}

.toolbar-group:last-child {
    border-right: none;
}

button {
    background: #e91e63;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    font-weight: 500;
}

button:hover {
    background: #d81b60;
    transform: translateY(-1px);
}

button.active {
    background: #e91e63;
    box-shadow: 0 0 10px rgba(233, 30, 99, 0.45);
}

button.disabled {
    background: grey !important;
    box-shadow: 0 0 10px rgba(233, 30, 99, 0.45);
    cursor: not-allowed;
}

button.danger {
    background: #ff5722;
}

button.danger:hover {
    background: #e64a19;
}

input[type="number"],
input[type="text"],
select {
    padding: 6px 10px;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 13px;
    background: #3d3d3d;
    color: #fff;
    height: 33px;
    width: auto;
    min-width: 120px;
}

label {
    font-size: 13px;
    font-weight: 500;
    color: #ddd;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    background: #2d2d2d;
    width: 250px;
    padding: 20px;
    overflow-y: auto;
    border-right: 2px solid #404040;
}

.sidebar h3 {
    margin-bottom: 15px;
    color: #e91e63;
    font-size: 16px;
    border-bottom: 2px solid #404040;
    padding-bottom: 8px;
}

.stat-item {
    background: #3d3d3d;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 10px;
    border-left: 3px solid #e91e63;
}

.stat-label {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.workspace {
    flex: 1;
    overflow: auto;
    background: #d9d9d9;
    position: relative;
}

.workspace-inner {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 40px;
}

.canvas-container {
    display: inline-block;
    transform-origin: top center;
    transition: transform 0.2s ease;
}

.planche {
    position: relative;
    background: white;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
}

.grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.element {
    position: absolute;
    cursor: move;
    user-select: none;
    z-index: 10;
}

.element img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.element.text-element {
    background: transparent;
    border: 1px dashed transparent;
    padding: 2px 4px;
    min-width: 20px;
    min-height: 20px;
    white-space: pre-wrap;
    word-wrap: break-word;
    width: fit-content !important;
    height: auto !important;
    display: inline-block;
    line-height: 1.2;
    outline: none;
}

.element.text-element.selected {
    border-color: #e91e63;
}

.element.text-element:focus {
    outline: none;
}

.element.shape-element.circle {
    border-radius: 50%;
}

.element.shape-element.triangle,
.element.shape-element.heart,
.element.shape-element.star {
    background-color: transparent !important;
}

.selection-box {
    position: absolute;
    pointer-events: none;
    outline: 2px solid #e91e63;
    outline-offset: 2px;
    z-index: 0;
}

.resize-handle {
    position: absolute;
    background: #e91e63;
    border: 2px solid white;
    width: 10px;
    height: 10px;
    z-index: 100;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #ffb300;
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    z-index: 100;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.rotate-handle:active {
    cursor: grabbing;
}

.planche-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.extend-button {
    background: #e91e63;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

.extend-button:hover {
    background: #d81b60;
    transform: scale(1.05);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
}

.color-picker {
    width: 35px;
    height: 35px;
    border: 2px solid #555;
    border-radius: 4px;
    cursor: pointer;
}

.mobile-only {
    display: none;
}

.desktop-only {
    display: none;
}

@media screen and (min-width: 768px) {
    .desktop-only {
        display: flex;
    }
}

.mobile-plus-menu { display: none; }

#imageInput {
    display: none;
}

.dimension-display {
    position: absolute;
    background: rgba(30, 30, 30, 0.92);
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    height: auto !important;
    width: auto !important;
    max-height: 30px !important;
    line-height: 1.2;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
}

.properties-panel {
    background: #3d3d3d;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
}

.property-item {
    margin-bottom: 12px;
}

.property-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
}

.property-item input,
.property-item select {
    width: 100%;
}

#hiddenCanvas {
    display: none;
}

button img {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 6px;
}

/* Mobile layout */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }
    select {
        height: 36px;
    }
    .main-container {
        margin-top: 112px;
        display: block;
        height: calc(100vh - 112px);
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        height: 64px;
        display: flex;
        align-items: center;
        width: auto;
        gap: 10px;
        padding: 8px 10px;
        background: #2d2d2d;
        border-right: none;
        border-bottom: 1px solid #404040;
        overflow-x: auto;
        white-space: nowrap;
    }

    .sidebar h3 {
        display: none;
    }

    #propertiesPanel {
        display: none !important;
    }

    .stat-item {
        min-width: 140px;
        margin-bottom: 0;
        padding: 3px;
    }

    .stat-value {
        font-size: 16px;
    }

    .toolbar {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        height: 47px;
        z-index: 1000;
        padding: 6px 10px;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        align-items: center;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        border-bottom: 1px solid #404040;
        -webkit-overflow-scrolling: touch;
    }

    .toolbar-group {
        border-right: none;
        padding-right: 0;
        gap: 8px;
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .toolbar button,
    .toolbar select {
        font-size: 12px;
        height: 36px;
        padding: 0 12px;
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .toolbar button { display: inline-flex; align-items: center; }
    .toolbar select { display: inline-block; }

    .toolbar > * {
        flex: 0 0 auto;
    }

    .toolbar-group {
        flex-wrap: nowrap;
    }

    .toolbar select {
        min-width: 100px;
    }

    .color-picker-wrapper label {
        display: none;
    }

    .toolbar #shapeType,
    .toolbar .color-picker-wrapper {
        display: none !important;
    }

    #addText,
    #addImage,
    #addShape {
        display: none;
    }

    .mobile-only {
        display: inline-flex;
    }

    .mobile-plus-menu { display: none !important; }
    .mobile-plus-menu.open { display: block !important; }

    .mobile-only.mobile-arrow {
        align-items: center;
        justify-content: center;
    }

    .plus-btn {
        width: auto;
        height: 100%;
        display: inline-grid;
        place-items: center;
        background: #4a4a4a;
        border: 1px solid #5a5a5a;
        color: #fff;
        border-radius: 6px;
        font-size: 24px;
        line-height: 1;
    }

    .mobile-arrow {
        width: 36px;
        height: 36px;
        background: #4a4a4a;
        border: 1px solid #5a5a5a;
        color: #fff;
        border-radius: 6px;
        font-size: 18px;
        padding: 0 10px;
    }

    .color-picker {
        width: 36px;
        height: 36px;
    }

    .planche-controls {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        bottom: 16px;
        z-index: 1002;
        right: auto;
    }

    .workspace {
        height: 100%;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 80px;
    }

    .extend-button {
        padding: 6px 16px;
        font-size: 14px;
        border-radius: 20px;
    }

    .mobile-plus-menu {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: #3f3f3f;
        border-bottom: 1px solid #404040;
        box-shadow: 0 8px 20px rgba(0,0,0,0.35);
        padding: 10px;
        z-index: 1001;
    }
    .mobile-plus-menu.open { display: block; }
    .mobile-plus-menu .mobile-menu-row {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
        overflow: hidden;
    }
    .mobile-plus-menu .slot {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        background: #2d2d2d;
        border: 1px solid #4a4a4a;
        border-radius: 6px;
        padding:0;
    }
    .mobile-plus-menu select { min-width: 140px; }
    .mobile-plus-menu .mobile-menu-actions {
        display: flex;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    .mobile-plus-menu .mobile-action {
        background: #e91e63;
        color: #fff;
        border: none;
        border-radius: 6px;
        height: 36px;
        padding: 0 14px;
        font-weight: 600;
        flex: 0 0 auto;
    }
}

/* Fabric.js specific - canvas visible */
.canvas-wrapper canvas {
    display: block !important;
}

/* Modale import Excel */
.designer-import-modal {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: none;
    align-items: center;
    justify-content: center;
}

.designer-import-modal.open {
    display: flex;
}

.designer-import-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.designer-import-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(420px, calc(100vw - 32px));
    background: #2d2d2d;
    border: 1px solid #4a4a4a;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.designer-import-modal__dialog h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.designer-import-modal__hint {
    margin-bottom: 16px;
    font-size: 13px;
}

.designer-import-modal__hint a {
    color: #ff80ab;
    text-decoration: underline;
}

.designer-import-modal__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.designer-import-modal__field label {
    font-size: 13px;
    color: #ddd;
}

.designer-import-modal__field input[type="number"],
.designer-import-modal__field select {
    width: 100%;
}

.designer-import-modal__file {
    display: flex;
    align-items: center;
    gap: 10px;
}

.designer-import-modal__file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.designer-import-modal__file-btn {
    display: inline-block;
    background: #f3f3f3;
    color: #222;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.designer-import-modal__file-name {
    color: #ddd;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.designer-import-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.designer-import-modal__btn-cancel {
    background: #555 !important;
}

.designer-import-modal__btn-cancel:hover {
    background: #666 !important;
}
