* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    user-select: none;
    height: 100vh;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    margin: 0;
    background: white;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.header {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    text-align: center;
    flex-shrink: 0;
}

.header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.header p {
    margin: 5px 0 0 0;
    font-size: 0.9rem;
}

.toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.main-content {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    height: calc(100vh - 140px);
    flex: 1;
    overflow: hidden;
}

/* Painel de Elementos */
.elements-panel {
    background: #f8f9fa;
    border-right: 1px solid #ddd;
    padding: 15px;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.elements-panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
    font-size: 1rem;
}

.element-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: grab;
    transition: all 0.3s;
}

.element-item:hover {
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.element-item:active {
    cursor: grabbing;
}

.element-icon {
    font-size: 20px;
    margin-right: 10px;
    width: 25px;
    text-align: center;
}

/* Área de Design */
.design-area {
    position: relative;
    background: #ffffff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.workspace-area {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-image:
        linear-gradient(to right, #f0f0f0 1px, transparent 1px),
        linear-gradient(to bottom, #f0f0f0 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: var(--grid-offset-x, 0) var(--grid-offset-y, 0);
    transition: background-position 0.1s ease;
}

.workspace-area.grid-hidden {
    background-image: none;
}

/* Canvas infinito */
.label-canvas {
    position: absolute;
    background: white;
    border: 2px solid #007bff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform-origin: center;
    min-width: 200px;
    min-height: 150px;
    cursor: grab;
    user-select: none;
}

.label-canvas:active {
    cursor: grabbing;
}

/* Área de trabalho infinita com grid sempre visível */
.workspace-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    background: transparent;
    transform-origin: 0 0;
    z-index: 1;
}

/* Grid de fundo fixo para sensação de espaço infinito */
.design-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
            linear-gradient(to right, #d0d0d0 1px, transparent 1px),
            linear-gradient(to bottom, #d0d0d0 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: var(--grid-offset-x) var(--grid-offset-y);
    z-index: 0;
    pointer-events: none;
    transition: background-position 0.05s ease;
}

/* Grid secundário mais sutil - TEMPORARIAMENTE DESABILITADO
.design-area::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
            linear-gradient(to right, #e8e8e8 1px, transparent 1px),
            linear-gradient(to bottom, #e8e8e8 1px, transparent 1px);
    background-size: 10px 10px;
    background-position: var(--subgrid-offset-x) var(--subgrid-offset-y);
    z-index: 0;
    pointer-events: none;
    transition: background-position 0.05s ease;
    opacity: 0.5;
}
*/

/* Esconder grid quando necessário */
.design-area.grid-hidden::before {
    display: none;
}

/* Contorno da etiqueta */
.label-outline {
    position: absolute;
    border: 3px dashed #007bff;
    background: rgba(0, 123, 255, 0.05);
    pointer-events: none;
    z-index: 5;
    border-radius: 3px;
}

/* Indicador de posição */
.position-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-family: monospace;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

/* Controles de navegação */
.navigation-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    z-index: 1000;
}

.navigation-controls button {
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid #ddd;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}

.navigation-controls button:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navigation-controls button:last-child {
    margin-bottom: 0;
}

.label-element {
    position: absolute;
    border: 1px dashed transparent;
    cursor: move;
    min-width: 50px;
    min-height: 20px;
    padding: 2px;
}

.label-element:hover {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.label-element.selected {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
    border-style: solid;
}

.label-element.multi-selected {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
    border-style: solid;
    border-width: 2px;
}

.label-element .resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #007bff;
    border: 1px solid white;
    border-radius: 50%;
    right: -4px;
    bottom: -4px;
    cursor: se-resize;
}

.text-element {
    font-family: Arial, sans-serif;
    color: #333;
    white-space: nowrap;
}

.barcode-element {
    background: repeating-linear-gradient(
            90deg,
            #000 0px,
            #000 2px,
            #fff 2px,
            #fff 4px
    );
    height: 60px;
    display: flex;
    align-items: end;
    justify-content: center;
    font-size: 10px;
    padding-bottom: 2px;
}

.qrcode-element {
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="white"/><rect x="0" y="0" width="30" height="30" fill="black"/><rect x="70" y="0" width="30" height="30" fill="black"/><rect x="0" y="70" width="30" height="30" fill="black"/><rect x="40" y="40" width="20" height="20" fill="black"/></svg>');
    background-size: contain;
    width: 80px;
    height: 80px;
}

.line-element {
    background: #333;
    height: 2px;
    width: 100px;
}

.multi-select-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    z-index: 1001;
}

/* Painel de Propriedades */
.properties-panel {
    background: #f8f9fa;
    border-left: 1px solid #ddd;
    padding: 15px;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.properties-panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
    font-size: 1rem;
}

.property-group {
    margin-bottom: 20px;
}

.property-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.property-group input,
.property-group select,
.property-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.property-group textarea {
    resize: vertical;
    height: 60px;
}

.btn {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.zoom-slider {
    width: 100px;
}

.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 5px;
    padding: 20px;
    text-align: center;
    color: #666;
    margin: 20px;
}

.drop-zone.drag-over {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.code-output {
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    padding: 10px 20px;
    font-family: monospace;
    font-size: 12px;
    max-height: 150px;
    overflow-y: auto;
    flex-shrink: 0;
}

.code-output h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1rem;
}

.code-output pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}

.code-actions .btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* Modal de Importação */
.modal {
    display: none; /* Escondido por padrão */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    background-color: rgba(0,0,0,0.5); /* Fundo escurecido */
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: #fff;
    margin: auto;
    padding: 30px 25px 20px 25px;
    border-radius: 10px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    position: relative;
    animation: modalFadeIn 0.2s;
}

.modal-content h2 {
    margin-top: 0;
    font-size: 1.3rem;
    color: #007bff;
    margin-bottom: 18px;
}

.modal-content .close {
    position: absolute;
    top: 12px;
    right: 18px;
    font-size: 1.5rem;
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-content .close:hover {
    color: #dc3545;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 200px 1fr 250px;
    }
    
    .elements-panel,
    .properties-panel {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .header p {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        height: calc(100vh - 120px);
    }

    .elements-panel,
    .properties-panel {
        border: none;
        border-bottom: 1px solid #ddd;
        max-height: 200px;
    }
    
    .toolbar {
        padding: 8px 15px;
        gap: 8px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .navigation-controls {
        top: 5px;
        left: 5px;
        gap: 3px;
    }
    
    .navigation-controls button {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    
    .position-indicator {
        bottom: 5px;
        right: 5px;
        font-size: 0.7rem;
        padding: 3px 8px;
    }
}