* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Hide file input */
#pdfFile {
    display: none;
}

/* Canvas area maximization */
#canvasArea {
    display: none;
    background: #f8f9fa;
}

#canvasArea.active {
    display: block;
}

#pdfCanvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    max-width: 100%;
}

/* Sidebar styling */
.sidebar-panel {
    min-height: 0;
}

.sidebar-panel h6 {
    font-weight: 600;
    color: #333;
    margin: 0;
}

.plans-list,
.takeoffs-list {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.plan-item,
.takeoff-item {
    background: white;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    border-left: 3px solid #0d6efd;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.plan-item:hover,
.takeoff-item:hover {
    background: #f8f9fa;
    transform: translateX(3px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.plan-item.active,
.takeoff-item.active {
    background: #e7f1ff;
    border-left-color: #0d6efd;
}

.plan-name,
.takeoff-name {
    font-weight: 500;
    color: #333;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-date,
.takeoff-date {
    font-size: 0.75rem;
    color: #6c757d;
}

.empty-message {
    text-align: center;
    color: #6c757d;
    padding: 1.5rem;
    font-size: 0.875rem;
}

/* PDF controls */
.pdf-controls {
    background: #f8f9fa;
}

.page-info {
    white-space: nowrap;
}

/* Canvas controls */
.canvas-controls {
    background: #f8f9fa;
}

/* Drawing mode buttons */
.draw-mode-btn {
    flex-shrink: 0;
}

.draw-mode-btn.active {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.delete-plan-btn {
    opacity: 0.6;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.plan-item:hover .delete-plan-btn {
    opacity: 1;
}

.delete-plan-btn:hover {
    opacity: 1;
    background-color: #dc3545 !important;
    color: white !important;
    border-color: #dc3545 !important;
}

/* Measurement panel */
.measurement-panel {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.5rem;
    flex-shrink: 0;
}

.measurement-list {
    max-height: 220px;
    overflow-y: auto;
}

.measurement-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s;
}

.measurement-item:hover {
    background: #f0f4ff;
}

.measurement-item.selected {
    background: #cfe2ff;
}

.measurement-item .m-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.measurement-item .m-value {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #6c757d;
    font-variant-numeric: tabular-nums;
}

.measurement-item .m-delete-btn {
    flex-shrink: 0;
    display: none;
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0 0.1rem;
    font-size: 0.9rem;
    line-height: 1;
    margin-left: 0.2rem;
}

.measurement-item:hover .m-delete-btn {
    display: block;
}

.measurement-totals {
    border-top: 1px solid #dee2e6;
    padding-top: 0.4rem;
    font-size: 0.78rem;
    color: #495057;
}

.measurement-totals .total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.1rem 0.4rem;
}

/* Canvas right-click context menu */
.canvas-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    min-width: 170px;
    padding: 0.25rem 0;
    user-select: none;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.context-menu-item:hover {
    background: #f0f4ff;
    color: #0055ff;
}

.context-menu-item.context-menu-danger:hover {
    background: #fff0f0;
    color: #dc3545;
}

.context-menu-divider {
    height: 1px;
    background: #dee2e6;
    margin: 0.25rem 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Responsive: hide sidebars on smaller screens */
@media (max-width: 991px) {
    .sidebar-panel {
        display: none;
    }

    #plansSidebar,
    #takeoffsSidebar {
        position: fixed;
        top: 0;
        width: 250px;
        height: 100%;
        z-index: 1040;
        background: white;
    }

    #plansSidebar {
        left: 0;
        border-right: 1px solid #dee2e6;
    }

    #takeoffsSidebar {
        right: 0;
        border-left: 1px solid #dee2e6;
    }

    #canvasArea {
        margin: 0;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .navbar,
    .sidebar-panel,
    .btn,
    .pdf-controls,
    .canvas-controls {
        display: none;
    }

    #canvasArea {
        display: block;
        overflow: visible;
    }

    #pdfCanvas {
        max-width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.plan-item,
.takeoff-item {
    animation: fadeIn 0.3s ease;
}

