/* Whiteboard Editor Styles */

.whiteboard-editor {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100% !important;
    width: 100% !important;
    background: #f5f5f5 !important;
    overflow: hidden !important;
}

.whiteboard-toolbar {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.75rem 1rem !important;
    background: white !important;
    border-bottom: 1px solid #e0e0e0 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    z-index: 1000 !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    min-height: 60px !important;
}

/* Force all toolbar buttons to be visible */
.whiteboard-toolbar .btn,
.whiteboard-toolbar button,
.whiteboard-toolbar .btn-group,
.whiteboard-toolbar .form-select,
.whiteboard-toolbar .form-control,
.whiteboard-toolbar input {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure Bootstrap button styles work */
.whiteboard-toolbar .btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
    border-radius: 0.2rem !important;
}

.whiteboard-toolbar .btn-outline-secondary {
    color: #6c757d !important;
    border-color: #6c757d !important;
}

.whiteboard-toolbar .btn-outline-secondary:hover {
    color: #fff !important;
    background-color: #6c757d !important;
    border-color: #6c757d !important;
}

.whiteboard-toolbar .btn-primary {
    color: #fff !important;
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Ensure buttons are visible */
.toolbar-section .btn {
    white-space: nowrap;
}

.toolbar-section .btn-group {
    display: inline-flex;
}

/* Ensure dropdowns work */
.toolbar-section .dropdown {
    position: relative;
}

.toolbar-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-divider {
    width: 1px;
    height: 30px;
    background: #e0e0e0;
    margin: 0 0.5rem;
    flex-shrink: 0;
}

/* Active button state */
.btn.active,
.btn-outline-secondary.active {
    background-color: #0d6efd !important;
    color: white !important;
    border-color: #0d6efd !important;
}

/* Ensure form controls in toolbar are visible */
.toolbar-section .form-select,
.toolbar-section .form-control {
    min-width: 100px;
}

.color-picker {
    width: 40px;
    height: 32px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    cursor: pointer;
}

.canvas-container {
    position: absolute !important;
    top: 60px !important;  /* Below toolbar */
    left: 0 !important;
    right: 0 !important;
    bottom: 40px !important;  /* Above status bar */
    overflow: hidden !important;
    background: white !important;
}

.canvas-container canvas {
    cursor: crosshair;
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    background: white !important;
    /* width and height set by JavaScript */
}

.canvas-container canvas.panning {
    cursor: grab;
}

.grid-overlay {
    pointer-events: none;
}

.preview-overlay {
    pointer-events: none;
    z-index: 10;
}

.preview-shape,
.preview-connector {
    stroke-dasharray: 5, 5;
    opacity: 0.7;
}

.pen-preview-overlay {
    pointer-events: none;
    z-index: 10;
}

.preview-pen-stroke {
    opacity: 0.8;
}

/* Selection styles */
.selection-box {
    position: absolute;
    border: 2px solid #0d6efd;
    pointer-events: none;
    z-index: 100;
}

.selection-box.multi-selection {
    border-color: #6c757d;
    border-style: dashed;
}

.selection-count {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #0d6efd;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 2px solid #0d6efd;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
}

.resize-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.resize-handle.n { top: -4px; left: calc(50% - 4px); cursor: n-resize; }
.resize-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.resize-handle.e { top: calc(50% - 4px); right: -4px; cursor: e-resize; }
.resize-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }
.resize-handle.s { bottom: -4px; left: calc(50% - 4px); cursor: s-resize; }
.resize-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.resize-handle.w { top: calc(50% - 4px); left: -4px; cursor: w-resize; }

.rotation-handle {
    position: absolute;
    top: -30px;
    left: calc(50% - 12px);
    width: 24px;
    height: 24px;
    background: white;
    border: 2px solid #0d6efd;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.rotation-handle:active {
    cursor: grabbing;
}

/* Multi-select rectangle */
.multi-select-rect {
    position: absolute;
    border: 2px dashed #0d6efd;
    background: rgba(13, 110, 253, 0.1);
    pointer-events: none;
    z-index: 50;
}

/* Task badges */
.task-badge {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 200;
    max-width: 200px;
}

.task-badge.completed {
    background: #d1e7dd;
    border-color: #a3cfbb;
}

.task-badge.high-priority {
    border-color: #dc3545;
    border-width: 2px;
}

.task-badge-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remote cursors */
.remote-cursor {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    transition: left 0.1s, top 0.1s;
}

.remote-cursor-pointer {
    width: 0;
    height: 0;
    border-left: 8px solid var(--cursor-color);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.remote-cursor-label {
    position: absolute;
    top: 16px;
    left: 8px;
    background: var(--cursor-color);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    white-space: nowrap;
}

/* Active users panel */
.active-users {
    display: flex;
    gap: 4px;
    align-items: center;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0d6efd;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* Ensure all toolbar items are visible */
.whiteboard-toolbar * {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Debug: Make sure toolbar has height */
.whiteboard-toolbar {
    min-height: 60px;
}

.active-users-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    z-index: 500;
}

.active-user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.active-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--user-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
}

.active-user-name {
    font-size: 0.875rem;
}

/* Status bar */
.whiteboard-statusbar {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 40px !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    font-size: 0.875rem;
    color: #6c757d;
    z-index: 100;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Layer panel */
.layer-panel {
    position: absolute;
    right: 20px;
    top: 70px;
    width: 300px;
    max-height: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.layer-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.layer-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.layer-list {
    display: flex;
    flex-direction: column;
}

.layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.layer-item:hover {
    background: #f8f9fa;
}

.layer-item.active {
    background: #e7f1ff;
}

.layer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.layer-icon {
    color: #6c757d;
}

.layer-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
}

.layer-actions {
    display: flex;
    gap: 4px;
}

/* Comments panel */
.comments-panel {
    position: absolute;
    right: 20px;
    top: 70px;
    width: 350px;
    max-height: 600px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.comments-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.comments-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-thread {
    display: flex;
    flex-direction: column;
}

.comment-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #0d6efd;
}

.comment-item.resolved {
    opacity: 0.7;
    border-left-color: #6c757d;
}

.comment-item.comment-reply {
    margin-left: 24px;
    border-left-color: #6c757d;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.comment-author {
    font-weight: 600;
}

.comment-date {
    color: #6c757d;
}

.comment-content {
    font-size: 0.875rem;
    margin-bottom: 8px;
    white-space: pre-wrap;
}

.comment-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.comment-resolved-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: #d1e7dd;
    color: #0f5132;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-top: 4px;
}

.comment-replies {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-toggle-replies {
    margin-top: 8px;
    font-size: 0.75rem;
}

/* Presentation mode */
.presentation-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.presentation-exit {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2001;
}

.presentation-canvas-container {
    max-width: 90vw;
    max-height: 90vh;
}

.presentation-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    align-items: center;
    background: rgba(255,255,255,0.9);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Recording indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #dc3545;
    color: white;
    border-radius: 4px;
    font-size: 0.875rem;
}

.recording-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Zoom controls (mobile) */
.zoom-controls {
    position: absolute;
    bottom: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.zoom-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .toolbar-section {
        gap: 0.25rem;
    }
    
    .toolbar-divider {
        display: none;
    }
    
    .layer-panel,
    .comments-panel {
        width: calc(100vw - 40px);
        max-width: 400px;
    }
}
