/* New Layout CSS matching mockup design */

/* Container with sidebar layout */
.wp-whiteboard-container {
    display: flex;
    min-height: calc(100vh - 120px);
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/* Left Sidebar */
.whiteboard-sidebar {
    width: 60px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 0;
    gap: 2rem;
    position: fixed;
    left: 10px;
    top: 110px;
    z-index: 100;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

/* Tool Buttons in Sidebar */
.whiteboard-sidebar .tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 1.5rem;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.whiteboard-sidebar .tool-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.whiteboard-sidebar .tool-btn.active {
    background: #8b5cf6;
    color: #ffffff;
}

.whiteboard-sidebar .tool-btn svg {
    width: 24px;
    height: 24px;
}

/* Color Presets in Sidebar */
.color-preset {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
}

.color-preset:hover {
    border-color: #9ca3af;
    transform: scale(1.1);
}

.color-preset.active {
    border-color: #374151;
    border-width: 3px;
}

/* Main Content Area */
.whiteboard-main-content {
    flex: 1;
    padding: 0.5rem 0 2rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Tool Section */
.whiteboard-tool-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    width: 100%;
    position: sticky;
    top: 70px;
    z-index: 50;
}

.tool-section-left,
.tool-section-middle,
.tool-section-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-section-btn {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-section-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.tool-section-btn:active {
    transform: scale(0.95);
}

.tool-section-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.tool-section-btn-light {
    background: #ffffff;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.tool-section-btn-light:hover {
    background: #f9fafb;
    color: #374151;
}

.tool-section-btn-danger {
    background: #ef4444;
    color: #ffffff;
}

.tool-section-btn-danger:hover {
    background: #dc2626;
    color: #ffffff;
}

#upload-pdf-btn {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

#upload-pdf-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Canvas and Webcam Container */
.whiteboard-canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #ffffff;
    color: #6b7280;
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.zoom-btn:hover {
    background: #f3f4f6;
    color: #374151;
    transform: scale(1.05);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* Mobile zoom controls */
@media (max-width: 767px) {
    .zoom-controls {
        bottom: 0.5rem;
        right: 0.5rem;
        padding: 0.25rem;
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
    }
    
    .zoom-btn svg {
        width: 14px;
        height: 14px;
    }
}

#whiteboard-canvas,
#webcam-video {
    transition: opacity 0.3s ease-in-out;
}

#whiteboard-canvas.fade-out,
#webcam-video.fade-out {
    opacity: 0;
}

#webcam-video {
    background: #000000;
    object-fit: contain;
}

/* Canvas Controls (Undo/Redo above canvas) */
.canvas-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-self: flex-start;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

/* Canvas Wrapper */
.whiteboard-canvas-wrapper {
    background: #ffffff;
    border-radius: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 0.6rem;
}

/* Force 16:9 aspect ratio when webcam is active */
.whiteboard-canvas-wrapper.webcam-active #whiteboard-canvas {
    width: 1280px !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
}

#whiteboard-canvas {
    display: block;
    cursor: crosshair;
    position: relative;
    z-index: 2;
    touch-action: none;
}

#pdf-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

#webcam-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    display: none;
}

/* Page Controls Below Preview */
.page-controls-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 0 1rem 0;
    margin: 0 auto;
    max-width: 1280px;
}

.page-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-control-btn:hover {
    background: #e5e7eb;
}

.page-add-btn {
    background: #3b82f6;
    color: #ffffff;
}

.page-add-btn:hover {
    background: #2563eb;
}

.page-indicator {
    padding: 0.5rem 1rem;
    background: #ffffff;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Size Control */
.size-control-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.size-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.size-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: all 0.2s;
}

.size-slider::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.size-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.size-slider::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.size-value {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    text-align: center;
    padding: 0.25rem;
    background: #f3f4f6;
    border-radius: 0.375rem;
    min-width: 2rem;
}

/* Fixed Header Navigation */
.whiteboard-fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    padding: 1rem 2rem;
}

.whiteboard-fixed-header.fullscreen-hidden {
    transform: translateY(-100%);
    opacity: 0;
}

/* In fullscreen: toolbar sticks at top since header is hidden */
body.fullscreen-active .whiteboard-main-content {
    padding-top: 0.25rem;
}

body.fullscreen-active .whiteboard-tool-section {
    top: 0;
    margin-bottom: 0.75rem;
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-container img {
    height: 1.8rem;
    width: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-action-btn {
    padding: 0.7rem;
    background: #7c3aed;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-action-btn:hover {
    background: #7c3aed;
}

.header-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.header-action-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    color: #ffffff;
}

/* Webcam Toggle Switch */
.webcam-toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f3f4f6;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.webcam-toggle-container:hover {
    background: #e5e7eb;
}

.webcam-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
}

.webcam-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.webcam-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 24px;
}

.webcam-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.webcam-toggle-switch input:checked + .webcam-toggle-slider {
    background-color: #8b5cf6;
}

.webcam-toggle-switch input:checked + .webcam-toggle-slider:before {
    transform: translateX(20px);
}

.webcam-icon {
    flex-shrink: 0;
}

.header-btn-with-label {
    padding: 0.5rem 1rem;
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.header-btn-green {
    background: #10b981;
}

.header-btn-green:hover {
    background: #059669;
}

.header-btn-purple {
    background: #8b5cf6;
}

.header-btn-purple:hover {
    background: #7c3aed;
}

.header-export-btn {
    padding: 0.5rem 1rem;
    background: #6366f1;
    color: #ffffff;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.header-export-btn:hover {
    background: #4f46e5;
}

/* Share Modal */
.share-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.share-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.share-modal-content {
    background: #ffffff;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.9);
    transition: transform 0.3s;
}

.share-modal-overlay.active .share-modal-content {
    transform: scale(1);
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.share-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.share-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.share-modal-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.share-modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.share-option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.share-option-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.share-option-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.share-option-icon-blue {
    background: #dbeafe;
    color: #3b82f6;
}

.share-option-icon-red {
    background: #fee2e2;
    color: #ef4444;
}

.share-option-icon-green {
    background: #d1fae5;
    color: #10b981;
}

.share-option-text {
    flex: 1;
}

.share-option-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
}

.share-option-desc {
    font-size: 0.875rem;
    color: #6b7280;
}

.header-export-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.header-export-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

#export-btn {
    padding: 0.5rem 1rem;
}

/* Page Preview Container */
.page-preview-container {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 1280px; /* Match canvas width */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
    user-select: none;
}

/* Sortable drag states */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    cursor: grabbing !important;
}

.sortable-drag {
    opacity: 0.8;
    transform: rotate(2deg);
}

.page-preview-container::-webkit-scrollbar {
    height: 6px;
}

.page-preview-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.page-preview-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.page-preview-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.page-preview-item {
    position: relative;
    flex-shrink: 0;
    cursor: grab;
    border: 3px solid transparent;
    border-radius: 0.5rem;
    transition: all 0.2s;
    background: #ffffff;
}

.page-preview-item:active {
    cursor: grabbing;
}

.page-preview-item:hover {
    border-color: #d1d5db;
}

.page-preview-item.active {
    border-color: #3b82f6;
}

.page-preview-item canvas {
    display: block;
    border-radius: 0.25rem;
}

.page-preview-number {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Footer */
footer.whiteboard-footer {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.footer-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-copyright {
    color: #6b7280;
    font-size: 0.875rem;
}

.footer-link {
    color: #7c3aed;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-link:hover {
    color: #6d28d9;
}

.footer-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0 0rem;
}

.footer-container .flex {
    display: flex;
}

.footer-container .flex-col {
    flex-direction: column;
}

.footer-container .sm\:flex-row {
    flex-direction: row;
}

.footer-container .items-center {
    align-items: center;
}

.footer-container .justify-between {
    justify-content: space-between;
}

.footer-container .gap-4 {
    gap: 1rem;
}

.footer-container .text-sm {
    font-size: 0.875rem;
}

.footer-container .text-gray-600 {
    color: #4b5563;
}

.footer-container .text-indigo-600 {
    color: #6366f1;
}

.footer-container .hover\:text-indigo-700:hover {
    color: #4f46e5;
}

.footer-container .font-medium {
    font-weight: 500;
}

.footer-container .transition {
    transition: all 0.2s;
}

.footer-container .gap-1 {
    gap: 0.25rem;
}

.footer-container svg {
    width: 1rem;
    height: 1rem;
}

/* Responsive Design */

/* Mobile Phones (320px - 767px) */
@media (max-width: 767px) {
    .whiteboard-sidebar {
        width: 50px;
        left: 5px;
        top: 90px;
        padding: 0.4rem 0;
        gap: 1rem;
    }
    
    .whiteboard-sidebar .tool-btn {
        width: 40px;
        height: 40px;
        border-radius: 1rem;
    }
    
    .whiteboard-sidebar .tool-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .color-preset {
        width: 28px;
        height: 28px;
    }
    
    .whiteboard-main-content {
        padding: 0.5rem 0.5rem 1rem 65px; /* Add left padding to account for sidebar */
        margin-left: 0;
    }
    
    .whiteboard-tool-section {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        gap: 0.25rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tool-section-btn {
        width: 36px;
        height: 36px;
    }
    
    .tool-section-btn svg {
        width: 1rem;
        height: 1rem;
    }
    
    .whiteboard-canvas-wrapper {
        width: 100%;
        overflow: hidden;
        border-radius: 0.5rem;
    }
    
    #whiteboard-canvas,
    #pdf-canvas,
    #webcam-video {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 0 auto;
    }
    
    .page-preview-container {
        padding: 0.5rem 0;
        gap: 0.25rem;
    }
    
    .page-thumbnail {
        width: 60px;
        height: 34px;
        border-radius: 0.25rem;
    }
    
    .header-container {
        padding: 0 0.5rem;
    }
    
    .whiteboard-header-title {
        font-size: 0.9rem;
    }
    
    .header-btn-with-label span {
        display: none;
    }
    
    .header-btn-with-label {
        width: 40px;
        height: 40px;
        padding: 0;
    }
}

/* Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .whiteboard-sidebar {
        width: 55px;
        left: 8px;
        top: 100px;
    }
    
    .whiteboard-sidebar .tool-btn {
        width: 44px;
        height: 44px;
    }
    
    .whiteboard-main-content {
        padding: 0.5rem 1rem 1.5rem 70px; /* Add left padding to account for sidebar */
        margin-left: 0;
    }
    
    .whiteboard-canvas-wrapper {
        max-width: 100%;
        width: 100%;
    }
    
    #whiteboard-canvas,
    #pdf-canvas,
    #webcam-video {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
    
    .page-preview-container {
        max-width: 100%;
    }
}

/* Small Laptops (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .whiteboard-main-content {
        padding: 0.5rem 1rem 1.5rem 75px; /* Add left padding to account for sidebar */
        margin-left: 0;
    }
    
    .whiteboard-canvas-wrapper {
        max-width: 100%;
        width: 100%;
    }
    
    #whiteboard-canvas,
    #pdf-canvas,
    #webcam-video {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
    }
}

/* Large Desktops (1280px+) */
@media (min-width: 1280px) {
    .whiteboard-main-content {
        padding: 0.5rem 1rem 1.5rem 1rem; /* Use fixed padding instead of percentage */
        margin-left: 0;
    }
    
    .whiteboard-canvas-wrapper {
        max-width: none; /* Remove max-width limitation */
        width: 100%;
    }
    
    #whiteboard-canvas,
    #pdf-canvas,
    #webcam-video {
        max-width: 100%;
        height: auto;
    }
}

/* Extra Large Screens (1440px+) */
@media (min-width: 1440px) {
    .whiteboard-main-content {
        padding: 1rem 0;
        margin-left: 0;
    }

    .whiteboard-canvas-wrapper {
        max-width: none; /* Remove max-width limitation */
    }
}

@media (min-width: 640px) {
    .footer-container .sm\:flex-row {
        flex-direction: row;
    }
}

/* Page Wrapper Adjustments */
.whiteboard-page-wrapper {
    min-height: calc(100vh - 60px);
    padding-top: 60px;
    display: flex;
    flex-direction: column;
}

.whiteboard-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}
