/* Presentation View Styles */

/* Page list styles */
#page-list {
    padding-bottom: 3rem; /* Add extra bottom padding so last item is fully visible when scrolling */
}

/* Page item styles */
.page-item {
    transition: all 0.2s ease;
}

.page-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-item.active {
    border-color: #7337FF !important;
    border-width: 2px !important;
    box-shadow: 0 0 0 0.2rem rgba(115, 55, 255, 0.25);
}

/* Drag and drop styles */
.page-item.drag-over {
    border-color: #7337FF !important;
    border-width: 2px !important;
    border-style: dashed !important;
    background-color: rgba(115, 55, 255, 0.05) !important;
    transform: scale(1.02);
}

/* Thumbnail preview container (Google Slides style) */
.page-thumbnail-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #ffffff;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

/* Scaled canvas clone inside thumbnail */
.page-thumbnail-preview .thumbnail-canvas-clone {
    position: absolute;
    top: 0;
    left: 0;
    width: 1200px;
    height: 675px;
    transform-origin: top left;
    pointer-events: none;
    background: white;
    border-radius: 8px;
}

/* Presentation sidebar */
#presentation-sidebar {
    width: 280px;
    flex-shrink: 0;
}

/* Sidebar content container - override Bootstrap p-3 bottom padding */
#presentation-sidebar > .p-3 {
    padding-bottom: 2rem !important; /* Increase bottom padding for scrolling */
}

/* Presentation canvas - multiple canvases, one per page */
/* All canvases are rendered but only active one is visible */
.presentation-canvas {
    width: 1200px;
    height: 675px; /* 16:9 ratio */
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: -1;
    flex-shrink: 0; /* Prevent shrinking */
    user-select: none; /* Prevent text selection on canvas to enable drag selection */
}

.presentation-canvas.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    z-index: 1;
}

/* Wrapper to contain and scale the canvas - margin handled by scale calculation */
.presentation-canvas-container {
    position: relative; /* Required for absolute positioned canvases */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0; /* Allow grid item to shrink */
    overflow: hidden; /* Prevent canvas from overflowing */
    opacity: 0; /* Start invisible, will be shown by JS after initialization */
    transition: none; /* No transition to prevent flicker */
}

/* Parent wrapper uses CSS Grid for height calculation */
#presentation-content-wrapper {
    height: 100%; /* Take full height of parent */
    display: grid;
    grid-template-rows: auto 1fr; /* Toolbar (auto) + Canvas container (remaining space) */
    min-height: 0;
}

/* Presentation table styles */
.presentation-table-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Text box styles */
.presentation-textbox {
    position: absolute;
    background-color: white;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 0;
    cursor: move;
    min-width: 50px;
    min-height: 30px;
    z-index: 10;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Disable transition during resize */
.presentation-textbox.resizing {
    transition: none;
    border-color: #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.presentation-textbox:hover {
    border-color: #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.presentation-textbox.selected {
    border-color: #7337FF;
    box-shadow: 0 0 0 3px rgba(115, 55, 255, 0.15);
}

/* Multi-selection style */
.presentation-textbox.multi-selected,
.presentation-table-box.multi-selected {
    /* No multi-selection effects for table box */
}

/* Page 1 title textbox - allow hover and selection effects like regular textboxes */
.page1-title-textbox {
    cursor: default !important;
}

.textbox-content {
    outline: none;
    word-wrap: break-word;
    min-height: 100%;
    width: 100%;
    padding: 12px;
    cursor: text;
    user-select: text; /* Allow text selection in textbox content */
}

/* Placeholder styling */
.textbox-content:empty:before {
    content: attr(data-placeholder);
    color: #adb5bd;
    pointer-events: none;
}

.textbox-content:focus:before {
    content: none;
}

.textbox-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 11;
}

.presentation-textbox:hover .textbox-delete-btn,
.presentation-textbox.selected .textbox-delete-btn,
.presentation-table-box:hover .textbox-delete-btn,
.presentation-table-box.selected .textbox-delete-btn {
    opacity: 1;
}

.textbox-delete-btn:hover {
    background-color: #bb2d3b;
    transform: scale(1.1);
}

.textbox-resize-handle {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 15px;
    height: 15px;
    background-color: #7337FF;
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 11;
}

.presentation-textbox:hover .textbox-resize-handle,
.presentation-textbox.selected .textbox-resize-handle {
    opacity: 1;
}

.textbox-resize-handle:hover {
    transform: scale(1.2);
}

/* Table box styles - no background or padding */
.presentation-table-box {
    position: absolute;
    background-color: transparent;
    border: none;
    cursor: default;
    min-width: 200px;
    min-height: 100px;
    z-index: 10;
    padding: 0;
    box-sizing: border-box;
}

/* Disable transition during resize */
.presentation-table-box.resizing {
    transition: none;
}

.presentation-table-box:hover {
    /* No hover effects */
}

.presentation-table-box.selected {
    /* No selection effects */
}

.presentation-table-box table {
    font-size: 0.75rem;
    margin: 0;
    width: auto;
    height: auto;
    table-layout: auto; /* Auto layout - each column fits content */
    border-collapse: collapse;
    box-sizing: border-box;
}

.presentation-table-box table th,
.presentation-table-box table td {
    padding: 0.375rem 0.5rem;
    /* white-space is controlled by JS based on mode */
    border: 1px solid #dee2e6;
    vertical-align: middle;
    outline: none;
    cursor: text;
    user-select: none; /* Prevent text selection by default */
}

/* Allow text selection only when focused */
.presentation-table-box table th:focus,
.presentation-table-box table td:focus {
    user-select: text;
}

.presentation-table-box table th {
    font-weight: 600;
    background-color: #f8f9fa;
}

.presentation-table-box table th.selected-cell,
.presentation-table-box table td.selected-cell {
    outline: 3px solid #7337FF;
    outline-offset: -3px;
    box-shadow: inset 0 0 0 1px #7337FF;
}

.presentation-table-box table tbody tr {
    height: auto;
}

.presentation-table-box table thead tr {
    height: auto;
}

/* Show resize handle on table box hover/select */
.presentation-table-box:hover .textbox-resize-handle,
.presentation-table-box.selected .textbox-resize-handle {
    opacity: 1;
}

/* Selection box for drag selection */
#selection-box {
    position: fixed;
    border: 2px solid #7337FF;
    background-color: rgba(115, 55, 255, 0.1);
    pointer-events: none;
    z-index: 9999;
    display: none;
}

/* Pseudo selection highlight (when number input is focused) */
.pseudo-selected {
    background-color: #7337FF !important;
    color: white !important;
}

/* Formatting toolbar styles */
#presentation-formatting-toolbar {
    animation: slideDown 0.2s ease;
}

#presentation-formatting-toolbar button.active {
    background-color: #7337FF;
    border-color: #7337FF;
    color: white;
}

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