* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: 
        radial-gradient(circle at 20px 20px, rgba(0,0,0,0.08) 1px, transparent 1px),
        linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    background-size: 40px 40px, 100% 100%;
    font-family: Arial, sans-serif;
    transition: background-color 0.3s ease;
}

#whiteboard {
    display: block;
    cursor: grab;
    background-color: transparent;
    border: none;
    outline: none;
}

#whiteboard:active {
    cursor: grabbing;
}

#zoom-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#zoom-indicator.visible {
    opacity: 1;
}

/* Disable text selection during dragging */
body.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Custom highlighter cursor */
.highlighter-cursor {
    cursor: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 2L12 6L16 2L14 4L16 6L20 10L16 14L8 10L4 6L8 2Z' fill='%23ffff00' stroke='%23ffa500' stroke-width='1'/%3E%3Cpath d='M8 10L16 14L18 16L12 22L6 16L8 10Z' fill='%23ffa500'/%3E%3C/svg%3E") 12 12, crosshair;
}

/* Custom scrollbar for better aesthetics */
::-webkit-scrollbar {
    display: none;
}

html {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Main toolbar (Excalidraw style) */
#main-toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #2c2c2f;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    transform: translateX(0);
    opacity: 1;
}

/* Smooth slide-out animation when hidden */
#main-toolbar.hidden {
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

#main-toolbar.toolbar-hidden {
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

/* Close toolbar button */
.close-toolbar-btn {
    background: transparent;
    border: none;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #9ca3af;
    align-self: flex-end;
    margin-bottom: 4px;
}

.close-toolbar-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.tool-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #ced4da;
    position: relative;
}

.tool-btn svg {
    width: 18px;
    height: 18px;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tool-btn.active-tool {
    background: #a855f7;
    color: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tool-btn.active-tool:hover {
    background: #9333ea;
    color: #1f2937;
}

/* Tool shortcut numbers */
.tool-shortcut {
    position: absolute;
    bottom: -1px;
    right: -1px;
    font-size: 7px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.85);
    border-radius: 2px;
    width: 10px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Active tool shortcut styling */
.active-tool .tool-shortcut {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.8);
}

/* Toolbar separator */
.toolbar-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

/* Color palette (integrada na toolbar) */
#color-palette {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

#color-palette.visible {
    opacity: 1;
    max-height: 200px;
}

.color-btn {
    width: 24px;
    height: 16px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 2px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.color-btn.active {
    border-color: #8a2be2;
    border-width: 2px;
    box-shadow: 0 0 0 2px rgba(138, 43, 226, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.color-btn:hover {
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Global smooth transitions for theme switching */
body, #whiteboard, #main-toolbar, #zoom-indicator, #pdf-navigation, #color-palette, .sidebar-toggle-btn, #main-sidebar {
    transition: background-color 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                color 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Canvas specific smooth background transitions */
#whiteboard {
    transition: background-color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Tema escuro usando classe theme-dark */
body.theme-dark {
    background-color: #1e1e1e !important;
}

body.theme-dark #whiteboard {
    background-color: #2d2d2d !important;
}

body.theme-dark #zoom-indicator {
    background-color: rgba(255, 255, 255, 0.9);
    color: #1e1e1e;
}

/* PDF Navigation tema escuro */
body.theme-dark #pdf-navigation {
    background-color: rgba(44, 44, 47, 0.95);
    border: 1px solid #555;
}

body.theme-dark .nav-btn {
    color: #e0e0e0;
}

body.theme-dark .nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

body.theme-dark #page-indicator {
    color: #e0e0e0;
}

/* Paleta de cores tema escuro */
body.theme-dark #color-palette {
    background: rgba(44, 44, 47, 0.95);
    border: 1px solid #555;
}

body.theme-dark .color-btn {
    border-color: rgba(255, 255, 255, 0.2);
}

body.theme-dark #main-toolbar {
    background: rgba(44, 44, 47, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

body.theme-dark .sidebar-toggle-btn {
    background: rgba(44, 44, 47, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

/* Enhanced theme toggle button styles */
#bg-toggle {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#bg-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

#bg-toggle:hover::before {
    transform: translateX(100%);
}

#bg-toggle.active-tool {
    background-color: #a855f7;
    color: white;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

#bg-toggle svg {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#bg-toggle.active-tool svg {
    transform: rotate(180deg);
}

/* PDF Navigation */
#pdf-navigation {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

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

#page-indicator {
    font-size: 14px;
    color: #555;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}



/* Text editing toolbar */
.text-edit-toolbar {
    position: absolute;
    background: rgba(44, 44, 47, 0.95);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
    pointer-events: auto;
}

.text-edit-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-edit-group label {
    color: #e0e0e0;
    font-size: 12px;
    font-weight: 500;
    min-width: 60px;
}

.text-edit-group input[type="number"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #e0e0e0;
    padding: 4px 8px;
    font-size: 12px;
    width: 60px;
}

.text-edit-group select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #e0e0e0;
    padding: 4px 8px;
    font-size: 12px;
    flex: 1;
}

.text-edit-group input[type="color"] {
    width: 32px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.text-edit-btn {
    background: #007acc;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.text-edit-btn:hover {
    background: #005a9e;
}

.text-edit-btn:active {
    transform: translateY(1px);
}

/* Parte 1: Estilo para o textarea de edição in-place */
.professional-text-editor {
    resize: none; /* Remover alça de redimensionamento manual */
    overflow: hidden; /* Esconder barra de rolagem */
    box-sizing: border-box; /* Incluir padding no cálculo da altura */
    font-family: inherit; /* Herdar fonte do elemento pai */
    line-height: 1.2; /* Consistência com o texto renderizado */
    white-space: pre-wrap; /* Preservar quebras de linha e espaços */
    word-wrap: break-word; /* Quebrar palavras longas */
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle-btn svg {
    color: #666;
    transition: color 0.2s ease;
}

.sidebar-toggle-btn:hover svg {
    color: #333;
}

/* Main Sidebar */
.main-sidebar {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 220px;
    background: rgba(51, 51, 51, 0.95);
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.main-sidebar.is-open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.sidebar-content {
    padding: 20px;
}

/* Sidebar Header with Welcome Message */
.sidebar-header {
    margin-bottom: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.welcome-message {
    text-align: center;
}

.welcome-text {
    color: #a0a0a0;
    font-size: 12px;
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.username-text {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: block;
}

.sidebar-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
    text-align: center;
}

/* Menu sections */
.menu-section {
    margin-bottom: 14px;
}

.section-title {
    color: #a0a0a0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px 0;
    padding: 0 4px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0 0 6px 0;
}

.sidebar-item {
    margin-bottom: 1px;
}

.sidebar-btn {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    text-align: left;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-btn:hover svg {
    opacity: 1;
}

/* Logout button specific styling */
.logout-btn {
    color: #ff6b6b !important;
    border: 1px solid rgba(255, 107, 107, 0.2);
    margin-top: 8px;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.1) !important;
    color: #ff5252 !important;
    border-color: rgba(255, 107, 107, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.2);
}

.logout-btn:active {
    background: rgba(255, 107, 107, 0.15) !important;
    transform: translateY(0);
}

.logout-btn svg {
    color: #ff6b6b;
}

.logout-btn:hover svg {
    color: #ff5252;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

/* Dark theme adjustments for sidebar */
.dark-theme .sidebar-toggle-btn {
    background: rgba(51, 51, 51, 0.9);
    border-color: #555;
}

.dark-theme .sidebar-toggle-btn:hover {
    background: rgba(51, 51, 51, 1);
}

.dark-theme .sidebar-toggle-btn svg {
    color: #ccc;
}

.dark-theme .sidebar-toggle-btn:hover svg {
    color: #fff;
}

.dark-theme .main-sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-color: #ddd;
}

.dark-theme .welcome-text {
    color: #666;
}

.dark-theme .username-text {
    color: #333;
}

.dark-theme .section-title {
    color: #666;
}

.dark-theme .sidebar-btn {
    color: #666;
}

.dark-theme .sidebar-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.dark-theme .sidebar-btn:active {
    background: rgba(0, 0, 0, 0.15);
}

.dark-theme .sidebar-divider {
    background: rgba(0, 0, 0, 0.1);
}

/* PDF Thumbnails Panel */
.thumbnails-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 70vh;
    background: rgba(44, 44, 47, 0.98);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    z-index: 1100;
    overflow: hidden;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.thumbnails-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
}

.thumbnails-header h3 {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.thumbnails-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.thumbnails-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.thumbnails-grid {
    padding: 16px;
    max-height: calc(70vh - 70px);
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Custom scrollbar for thumbnails grid */
.thumbnails-grid::-webkit-scrollbar {
    width: 6px;
}

.thumbnails-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.thumbnails-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.thumbnails-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.thumbnail-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    aspect-ratio: 3/4;
}

.thumbnail-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.thumbnail-item.active {
    border-color: #4a9eff;
    box-shadow: 0 0 0 1px #4a9eff, 0 8px 25px rgba(74, 158, 255, 0.3);
}

.thumbnail-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
    border-radius: 6px;
}

.thumbnail-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(5px);
}

/* Welcome Animation */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

.welcome-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.welcome-content {
    text-align: center;
    color: white;
    animation: welcomeSlideIn 1s ease-out;
}

.welcome-title {
    font-size: 3rem;
    font-weight: 300;
    margin-bottom: 1rem;
    animation: welcomeTitleGlow 2s ease-in-out infinite alternate;
}

.welcome-subtitle {
    font-size: 1.5rem;
    font-weight: 400;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.welcome-user {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 2rem;
    animation: welcomeUserPulse 1.5s ease-in-out;
}

.welcome-loader {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: welcomeSpin 1s linear infinite;
    margin: 0 auto;
}

@keyframes welcomeSlideIn {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes welcomeTitleGlow {
    from {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    }
    to {
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    }
}

@keyframes welcomeUserPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes welcomeSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


