/* Invoice Canvas Specific Styles */

/* Canvas Container */
.canvas-container {
    flex: 1;
    background: #e9ecef;
    position: relative;
    overflow: auto;
}

.canvas-wrapper {
    position: relative;
    min-height: 100%;
    padding: 50px;
}

/* Canvas Rulers */
.canvas-rulers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.ruler {
    background: #fff;
    border: 1px solid #ddd;
    position: absolute;
}

.ruler-horizontal {
    top: 0;
    left: 30px;
    right: 0;
    height: 30px;
    background-image: repeating-linear-gradient(
        to right,
        #ddd 0px,
        #ddd 1px,
        transparent 1px,
        transparent 10px
    );
}

.ruler-vertical {
    top: 30px;
    left: 0;
    bottom: 0;
    width: 30px;
    background-image: repeating-linear-gradient(
        to bottom,
        #ddd 0px,
        #ddd 1px,
        transparent 1px,
        transparent 10px
    );
}

/* Canvas Area */
.canvas-area {
    position: relative;
    margin: 30px 0 0 30px;
}

.invoice-canvas {
    position: relative;
    background: #fff;
    border: 2px solid #007bff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin: 20px auto;
    min-height: 400px;
    overflow: hidden;
}

.canvas-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0.3;
    background-image: 
        repeating-linear-gradient(0deg, #ccc 0px, #ccc 1px, transparent 1px, transparent 10px),
        repeating-linear-gradient(90deg, #ccc 0px, #ccc 1px, transparent 1px, transparent 10px);
    display: none;
}

.canvas-grid.show {
    display: block;
}

/* Canvas Elements */
.canvas-element {
    position: absolute;
    cursor: move;
    border: 1px dashed transparent;
    transition: border-color 0.2s;
    min-width: 20px;
    min-height: 16px;
    box-sizing: border-box;
}

.canvas-element:hover {
    border-color: #007bff;
}

.canvas-element.selected {
    border-color: #007bff;
    border-style: solid;
}

.canvas-element.dragging {
    opacity: 0.7;
    z-index: 1000;
}

/* Resize Handles */
.resize-handles {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #007bff;
    border: 1px solid #fff;
    border-radius: 50%;
    pointer-events: all;
}

.resize-handle.nw { top: 0; left: 0; cursor: nw-resize; }
.resize-handle.n { top: 0; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-handle.ne { top: 0; right: 0; cursor: ne-resize; }
.resize-handle.e { top: 50%; right: 0; transform: translateY(-50%); cursor: e-resize; }
.resize-handle.se { bottom: 0; right: 0; cursor: se-resize; }
.resize-handle.s { bottom: 0; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.sw { bottom: 0; left: 0; cursor: sw-resize; }
.resize-handle.w { top: 50%; left: 0; transform: translateY(-50%); cursor: w-resize; }

/* Selection Rectangle */
.selection-rectangle {
    position: absolute;
    border: 1px dashed #007bff;
    background: rgba(0, 123, 255, 0.1);
    pointer-events: none;
    z-index: 100;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    display: none;
    min-width: 150px;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 5px 0;
}

.context-menu li {
    margin: 0;
}

.context-menu li.divider {
    height: 1px;
    background: #eee;
    margin: 5px 0;
}

.context-menu a {
    display: block;
    padding: 8px 15px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
}

.context-menu a:hover {
    background: #f8f9fa;
    color: #333;
}

.context-menu i {
    margin-right: 8px;
    width: 14px;
}

/* Element Types */
.element-text {
    font-family: inherit;
    line-height: 1.2;
    word-wrap: break-word;
    overflow: hidden;
}

.element-line {
    border-bottom: 1px solid #000;
    height: 0;
}

.element-rectangle {
    border: 1px solid #000;
}

/* Drag and Drop */
.dragging-element {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.7;
    background: #f0f8ff;
    border: 1px dashed #007bff;
    padding: 5px 10px;
    border-radius: 4px;
}

/* Snap Guidelines */
.snap-line {
    position: absolute;
    background: #ff6b6b;
    z-index: 500;
    pointer-events: none;
}

.snap-line.horizontal {
    height: 1px;
    left: 0;
    right: 0;
}

.snap-line.vertical {
    width: 1px;
    top: 0;
    bottom: 0;
}

/* Zoom States */
.canvas-container.zoom-50 .invoice-canvas {
    transform: scale(0.5);
    transform-origin: top left;
}

.canvas-container.zoom-75 .invoice-canvas {
    transform: scale(0.75);
    transform-origin: top left;
}

.canvas-container.zoom-125 .invoice-canvas {
    transform: scale(1.25);
    transform-origin: top left;
}

.canvas-container.zoom-150 .invoice-canvas {
    transform: scale(1.5);
    transform-origin: top left;
}

.canvas-container.zoom-200 .invoice-canvas {
    transform: scale(2);
    transform-origin: top left;
}

/* Loading States */
.canvas-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 18px;
}

.canvas-loading i {
    margin-right: 10px;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.element-creating {
    animation: pulse 1s infinite;
}

/* Print Styles */
@media print {
    .designer-toolbar,
    .designer-sidebar,
    .canvas-rulers,
    .canvas-grid,
    .resize-handles {
        display: none !important;
    }
    
    .canvas-container {
        background: white;
        padding: 0;
    }
    
    .invoice-canvas {
        border: none;
        box-shadow: none;
        margin: 0;
    }
}
