/* =============================================================================
   GB SLIDES - PowerPoint-like Presentation CSS
   General Bots Suite Component
   ============================================================================= */

:root {
    --slides-primary: #3b82f6;
    --slides-primary-dark: #2563eb;
    --slides-secondary: #64748b;
    --slides-accent: #f59e0b;
    --slides-background: #f1f5f9;
    --slides-surface: #ffffff;
    --slides-border: #e2e8f0;
    --slides-text: #1e293b;
    --slides-text-light: #64748b;
    --slides-danger: #ef4444;
    --slides-success: #22c55e;
    --slides-sidebar-width: 200px;
    --slides-toolbar-height: 52px;
    --slides-status-height: 32px;
    --slides-properties-width: 260px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--slides-text);
    background: var(--slides-background);
}

/* =============================================================================
   MAIN CONTAINER
   ============================================================================= */

.slides-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */

.slides-sidebar {
    width: var(--slides-sidebar-width);
    background: var(--slides-surface);
    border-right: 1px solid var(--slides-border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
}

.slides-sidebar.collapsed {
    width: 0;
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--slides-border);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.sidebar-search {
    padding: 12px;
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--slides-border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search input:focus {
    border-color: var(--slides-primary);
}

.sidebar-search .search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slides-text-light);
}

.slide-thumbnails {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.slide-thumbnail {
    position: relative;
    margin-bottom: 8px;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.1s;
}

.slide-thumbnail:hover {
    border-color: var(--slides-secondary);
}

.slide-thumbnail.active {
    border-color: var(--slides-primary);
}

.slide-thumbnail-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--slides-surface);
    border: 1px solid var(--slides-border);
    border-radius: 4px;
    overflow: hidden;
}

.slide-thumbnail-number {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.sidebar-actions {
    padding: 12px;
    border-top: 1px solid var(--slides-border);
}

.btn-add-slide {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--slides-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add-slide:hover {
    background: var(--slides-primary-dark);
}

/* =============================================================================
   MAIN AREA
   ============================================================================= */

.slides-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* =============================================================================
   TOOLBAR
   ============================================================================= */

.slides-toolbar {
    height: var(--slides-toolbar-height);
    background: var(--slides-surface);
    border-bottom: 1px solid var(--slides-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    gap: 12px;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-center {
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--slides-border);
    margin: 0 4px;
}

.presentation-name-input {
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 4px;
    outline: none;
    min-width: 200px;
}

.presentation-name-input:hover {
    background: var(--slides-background);
}

.presentation-name-input:focus {
    background: var(--slides-background);
    box-shadow: 0 0 0 2px var(--slides-primary);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: var(--slides-text);
    transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
    background: var(--slides-background);
}

.btn-icon.active {
    background: var(--slides-primary);
    color: white;
}

.toolbar-select {
    padding: 6px 8px;
    border: 1px solid var(--slides-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--slides-surface);
    cursor: pointer;
    outline: none;
}

.toolbar-select:focus {
    border-color: var(--slides-primary);
}

.font-family {
    width: 120px;
}

.font-size {
    width: 70px;
}

.color-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.color-btn:hover {
    background: var(--slides-background);
}

.color-indicator {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    margin-top: 2px;
}

.color-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--slides-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--slides-primary-dark);
}

.collaborators {
    display: flex;
    gap: -8px;
}

.collaborator-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--slides-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-left: -8px;
}

.collaborator-avatar:first-child {
    margin-left: 0;
}

/* =============================================================================
   CANVAS AREA
   ============================================================================= */

.slide-canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--slides-background);
    overflow: auto;
    position: relative;
}

.slide-canvas {
    width: 960px;
    height: 540px;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    transform-origin: center center;
}

.slide-element {
    position: absolute;
    cursor: move;
    user-select: none;
}

.slide-element.selected {
    outline: 2px solid var(--slides-primary);
    outline-offset: 1px;
}

.slide-element.locked {
    cursor: not-allowed;
}

.slide-element-text {
    padding: 8px;
    white-space: pre-wrap;
    overflow: hidden;
}

.slide-element-text.editing {
    cursor: text;
    outline: none;
}

.slide-element-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.slide-element-shape {
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-element-shape svg {
    width: 100%;
    height: 100%;
}

/* Selection Handles */
.selection-handles {
    position: absolute;
    pointer-events: none;
}

.selection-handles.hidden {
    display: none;
}

.handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--slides-primary);
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
    cursor: pointer;
}

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

.rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: var(--slides-primary);
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
    cursor: grab;
}

.rotate-handle::before {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 15px;
    background: var(--slides-primary);
}

/* Cursor Indicators */
.cursor-indicators {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.cursor-indicator {
    position: absolute;
    pointer-events: none;
    transition: left 0.1s, top 0.1s;
}

.cursor-indicator::after {
    content: attr(data-name);
    position: absolute;
    top: 18px;
    left: 0;
    background: inherit;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: white;
    white-space: nowrap;
}

.cursor-indicator svg {
    width: 16px;
    height: 16px;
}

/* =============================================================================
   STATUS BAR
   ============================================================================= */

.slides-status-bar {
    height: var(--slides-status-height);
    background: var(--slides-surface);
    border-top: 1px solid var(--slides-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 12px;
    color: var(--slides-text-light);
}

.status-left,
.status-center,
.status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-zoom {
    width: 24px;
    height: 24px;
    border: 1px solid var(--slides-border);
    background: var(--slides-surface);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.btn-zoom:hover {
    background: var(--slides-background);
}

#save-status {
    color: var(--slides-text-light);
}

#save-status.saving {
    color: var(--slides-accent);
}

#save-status.saved {
    color: var(--slides-success);
}

/* =============================================================================
   PROPERTIES PANEL
   ============================================================================= */

.slides-properties {
    width: var(--slides-properties-width);
    background: var(--slides-surface);
    border-left: 1px solid var(--slides-border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
}

.slides-properties.collapsed {
    width: 0;
    transform: translateX(100%);
}

.properties-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--slides-border);
}

.properties-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.properties-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

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

.property-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--slides-text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.property-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.property-input {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.property-input span {
    font-size: 12px;
    color: var(--slides-text-light);
    width: 16px;
}

.property-input input[type="number"] {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--slides-border);
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}

.property-input input[type="number"]:focus {
    border-color: var(--slides-primary);
}

.property-row input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: var(--slides-border);
    border-radius: 2px;
    outline: none;
}

.property-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--slides-primary);
    border-radius: 50%;
    cursor: pointer;
}

/* =============================================================================
   CONTEXT MENU
   ============================================================================= */

.context-menu {
    position: fixed;
    background: var(--slides-surface);
    border: 1px solid var(--slides-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    padding: 6px 0;
    z-index: 1000;
}

.context-menu.hidden {
    display: none;
}

.context-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 13px;
}

.context-item:hover {
    background: var(--slides-background);
}

.context-item .shortcut {
    color: var(--slides-text-light);
    font-size: 12px;
}

.context-divider {
    height: 1px;
    background: var(--slides-border);
    margin: 6px 0;
}

/* =============================================================================
   MODALS
   ============================================================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--slides-surface);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content.modal-large {
    max-width: 640px;
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--slides-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slides-text-light);
}

.btn-close:hover {
    background: var(--slides-background);
    color: var(--slides-text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.theme-item {
    cursor: pointer;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.theme-item:hover {
    background: var(--slides-background);
}

.theme-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    margin-bottom: 8px;
}

.theme-item span {
    font-size: 12px;
    font-weight: 500;
}

/* Shape Grid */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.shape-btn {
    aspect-ratio: 1;
    border: 1px solid var(--slides-border);
    background: var(--slides-surface);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s;
}

.shape-btn:hover {
    border-color: var(--slides-primary);
    background: var(--slides-background);
}

/* Chart Modal */
.chart-type-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.chart-type-btn {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--slides-border);
    background: var(--slides-surface);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s;
}

.chart-type-btn:hover {
    border-color: var(--slides-secondary);
}

.chart-type-btn.active {
    border-color: var(--slides-primary);
    background: rgba(59, 130, 246, 0.05);
}

.chart-type-btn span {
    font-size: 12px;
    font-weight: 500;
}

.chart-data-input label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.chart-data-input textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--slides-border);
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    resize: vertical;
    outline: none;
}

.chart-data-input textarea:focus {
    border-color: var(--slides-primary);
}

/* =============================================================================
   PRESENTER MODE
   ============================================================================= */

.presenter-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 2000;
}

.presenter-modal.hidden {
    display: none;
}

.presenter-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.presenter-slide {
    max-width: 90vw;
    max-height: 80vh;
    background: white;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.1);
}

.presenter-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 20px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
}

.presenter-controls button {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
}

.presenter-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.presenter-slide-number {
    position: fixed;
    bottom: 20px;
    right: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1200px) {
    .slides-properties {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .slides-properties.collapsed {
        transform: translateX(100%);
    }
}

@media (max-width: 1024px) {
    .toolbar-center {
        display: none;
    }

    .slides-toolbar.expanded .toolbar-center {
        display: flex;
        position: absolute;
        top: var(--slides-toolbar-height);
        left: 0;
        right: 0;
        background: var(--slides-surface);
        border-bottom: 1px solid var(--slides-border);
        padding: 12px;
        z-index: 50;
    }
}

@media (max-width: 768px) {
    .slides-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .slides-sidebar.collapsed {
        transform: translateX(-100%);
    }

    .slide-canvas-container {
        padding: 12px;
    }

    .slide-canvas {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .presentation-name-input {
        min-width: 120px;
        font-size: 14px;
    }

    .btn-primary span {
        display: none;
    }

    .toolbar-select {
        font-size: 12px;
    }

    .font-family {
        width: 80px;
    }

    .font-size {
        width: 50px;
    }
}

/* =============================================================================
   PRINT
   ============================================================================= */

@media print {
    .slides-sidebar,
    .slides-toolbar,
    .slides-status-bar,
    .slides-properties,
    .context-menu,
    .modal {
        display: none !important;
    }

    .slides-container {
        display: block;
    }

    .slides-main {
        display: block;
    }

    .slide-canvas-container {
        padding: 0;
        background: none;
    }

    .slide-canvas {
        box-shadow: none;
        page-break-after: always;
        margin: 0 auto;
    }
}

/* =============================================================================
   ACCESSIBILITY
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .slide-thumbnail.active {
        outline: 3px solid var(--slides-primary);
    }

    .slide-element.selected {
        outline: 3px solid var(--slides-primary);
    }

    .btn-icon:focus,
    .btn-primary:focus {
        outline: 3px solid var(--slides-primary);
        outline-offset: 2px;
    }
}
