/* Base & Background */
body {
    background-color: #f5f5f4;
    background-image: radial-gradient(#d6d3d1 1px, transparent 1px);
    background-size: 24px 24px;
    overflow: hidden;
    color: #44403c;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d6d3d1;
    border-radius: 4px;
}

/* Board Container */
#board-container {
    position: relative;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.1);
    background: white;
    transition: width 0.3s, height 0.3s;
    border-radius: 6px;
    margin: 0 auto;
}

/* Canvas Layers */
canvas {
    position: absolute;
    top: 0;
    left: 0;
}
#pdf-render {
    z-index: 1;
    border-radius: 6px;
}
#drawing-layer {
    z-index: 10;
    border-radius: 6px;
}
#temp-layer {
    z-index: 15;
    pointer-events: none;
    border-radius: 6px;
}
#interaction-layer {
    z-index: 20;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    border-radius: 6px;
    touch-action: none;
}

/* Glass Panel Effect */
.glass-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

/* Text Editor Container */
.text-editor-container {
    position: fixed;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    box-shadow: 
        0 20px 40px -10px rgba(0, 0, 0, 0.15),
        0 8px 16px -6px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(231, 229, 228, 0.8);
    animation: textEditorFadeIn 0.15s ease-out;
}

@keyframes textEditorFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Text Editor Toolbar */
.text-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: linear-gradient(to bottom, #fafaf9, #f5f5f4);
    border-bottom: 1px solid #e7e5e4;
    border-radius: 16px 16px 0 0;
}

.text-size-select {
    padding: 6px 10px;
    padding-right: 28px;
    border: 1px solid #e7e5e4;
    border-radius: 8px;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    font-size: 13px;
    font-weight: 600;
    color: #44403c;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.text-size-select:hover {
    border-color: #d6d3d1;
    background-color: #fafaf9;
}

.text-size-select:focus {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.text-toolbar-divider {
    width: 1px;
    height: 24px;
    background: linear-gradient(to bottom, transparent, #d6d3d1, transparent);
    margin: 0 6px;
}

.text-format-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #78716c;
    transition: all 0.15s ease;
}

.text-format-btn:hover {
    background: white;
    border-color: #e7e5e4;
    color: #44403c;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.text-format-btn:active {
    transform: translateY(0);
}

.text-format-btn.active {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    border-color: #0d9488;
    color: white;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.text-format-btn.active:hover {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.4);
}

.text-format-btn b {
    font-weight: 800;
    font-size: 13px;
}

.text-format-btn i {
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 14px;
}

.text-format-btn u {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Text Input (textarea) */
.text-input-active {
    border: none;
    background: white;
    padding: 14px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: #1c1917;
    min-width: 220px;
    max-width: 500px;
    min-height: 48px;
    outline: none;
    resize: none;
    pointer-events: auto;
    line-height: 1.5;
    transition: background 0.15s ease;
}

.text-input-active:focus {
    background: #fafaf9;
}

.text-input-active::placeholder {
    color: #a8a29e;
    font-style: italic;
}

.text-input-active::selection {
    background: rgba(13, 148, 136, 0.2);
}

/* Text Info Button */
.text-info-btn {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: help;
    color: #a8a29e;
    transition: all 0.15s ease;
}

.text-info-btn:hover {
    color: #0d9488;
    background: rgba(13, 148, 136, 0.08);
}

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

/* Info Tooltip */
.text-info-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    right: -8px;
    background: #1c1917;
    color: white;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
    z-index: 2200;
}

.text-info-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 16px;
    width: 12px;
    height: 12px;
    background: #1c1917;
    transform: rotate(45deg);
    border-radius: 2px;
}

.text-info-btn:hover .text-info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Ensure textarea has rounded bottom corners */
.text-input-active {
    border-radius: 0 0 16px 16px;
}

.text-info-title {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0d9488;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #44403c;
}

.text-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    color: #d6d3d1;
    font-size: 12px;
}

.text-info-key {
    background: #292524;
    color: #fafaf9;
    padding: 3px 8px;
    border-radius: 5px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 600;
    min-width: 90px;
    text-align: center;
    border: 1px solid #44403c;
}

/* Widget Box */
.widget-box {
    position: absolute;
    background: white;
    padding: 1.25rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 60;
    display: none;
    border: 1px solid #e7e5e4;
    width: 260px;
}

/* View Menu */
#view-menu {
    position: absolute;
    top: 70px;
    right: 100px;
    background: white;
    border-radius: 12px;
    width: 220px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15);
    border: 1px solid #e7e5e4;
    z-index: 100;
    display: none;
    overflow: hidden;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #44403c;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s;
}
.menu-item:hover {
    background: #f5f5f4;
}
.menu-item i {
    width: 18px;
    height: 18px;
    color: #78716c;
}
.menu-divider {
    height: 1px;
    background: #e7e5e4;
    margin: 4px 0;
}

/* Tool Buttons */
.tool-btn {
    position: relative;
    transition: all 0.2s;
    color: #78716c;
}
.tool-btn:hover {
    background-color: #f5f5f4;
    color: #292524;
    transform: translateY(-1px);
}
.tool-btn:active {
    transform: translateY(0);
}
.active-tool {
    background-color: #f0fdfa !important;
    color: #0d9488 !important;
    box-shadow: inset 0 0 0 1px #ccfbf1;
}
.active-tool-marker {
    background-color: #fef9c3 !important;
    color: #ca8a04 !important;
    box-shadow: inset 0 0 0 1px #fef08a;
}
.active-tool-purple {
    background-color: #faf5ff !important;
    color: #9333ea !important;
    box-shadow: inset 0 0 0 1px #f3e8ff;
}
.active-tool-red {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
    box-shadow: inset 0 0 0 1px #fee2e2;
}

/* Color Dot */
.color-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: absolute;
    bottom: 6px;
    right: 6px;
    box-shadow: 0 0 0 1px white;
}

/* Pen Submenu */
.pen-submenu {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease 0.1s;
}
.pen-submenu::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 0;
    width: 12px;
    height: 100%;
}
.group:hover .pen-submenu {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
}

/* Status Badges */
.status-badge-ok {
    color: #0d9488;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.status-badge-missing {
    color: #a8a29e;
    display: flex;
    align-items: center;
    gap: 4px;
}
.status-badge-error {
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: help;
    font-weight: bold;
}

/* Curtain */
#curtain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0px;
    background-color: #292524;
    z-index: 50;
    display: none;
}
#curtain-handle {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 32px;
    background-color: #292524;
    border-radius: 0 0 16px 16px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    pointer-events: auto;
}

/* Auth Overlay */
#auth-overlay {
    position: fixed;
    inset: 0;
    background: #f5f5f4;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
#auth-overlay:not(.hidden) {
    display: flex;
}
.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

/* Password confirm field transition */
#confirm-password-group {
    transition: all 0.2s ease;
}
#confirm-password-group.hidden {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
#confirm-password-group:not(.hidden) {
    opacity: 1;
    max-height: 100px;
}

/* Media Markers */
.media-marker {
    position: absolute;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    z-index: 25;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid white;
}
.media-marker:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.5);
}
.media-marker.audio {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}
.media-marker.audio:hover {
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}
.media-marker.youtube {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}
.media-marker.youtube:hover {
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}
.media-marker.youtube svg {
    margin-left: 0;
}
.media-marker svg {
    width: 45%;
    height: 45%;
    margin-left: 3px;
}
.media-marker.audio svg,
.media-marker.youtube svg {
    margin-left: 0;
}

/* Resize handle */
.media-resize-handle {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: white;
    border: 2px solid #0d9488;
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}
.media-marker:hover .media-resize-handle {
    opacity: 1;
}
.media-marker.audio .media-resize-handle {
    border-color: #7c3aed;
}
.media-marker.youtube .media-resize-handle {
    border-color: #dc2626;
}

/* Media Overlay */
#media-overlay:not(.hidden) {
    display: flex;
}
#media-container video {
    max-height: 80vh;
}
#media-container iframe {
    border: none;
    min-height: 400px;
}
#media-container audio {
    background: #1c1917;
    border-radius: 8px;
}

/* ===== BORDBOEK SELECTOR ===== */
#bordboek-selector {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f5f5f4 0%, #e7e5e4 100%);
    z-index: 1900;
    overflow-y: auto;
    padding: 2rem;
}
#bordboek-selector:not(.hidden) {
    display: block;
}

.bordboek-selector-container {
    max-width: 1200px;
    margin: 0 auto;
}

.bordboek-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 4px 20px -2px rgba(40, 30, 20, 0.08);
}

.bordboek-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.bordboek-card {
    background: white;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 15px -3px rgba(40, 30, 20, 0.08);
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
    position: relative;
}

.bordboek-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px -5px rgba(40, 30, 20, 0.15);
    border-color: #0d9488;
}

.bordboek-card.selected {
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.bordboek-thumbnail {
    width: 100%;
    aspect-ratio: 210 / 297; /* A4 ratio */
    background: linear-gradient(135deg, #f5f5f4 0%, #e7e5e4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a8a29e;
    position: relative;
    overflow: hidden;
}

.bordboek-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f5f5f4;
}

.bordboek-thumbnail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.bordboek-thumbnail-placeholder i {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.bordboek-info {
    padding: 1rem 1.25rem;
}

.bordboek-title {
    font-weight: 700;
    font-size: 1rem;
    color: #292524;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bordboek-meta {
    font-size: 0.75rem;
    color: #78716c;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bordboek-meta i {
    width: 12px;
    height: 12px;
}

.bordboek-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: #0d9488;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bordboek-badge.no-book {
    background: #a8a29e;
}

/* Bordboek Actions */
.bordboek-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.bordboek-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.bordboek-action-btn.primary {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
}

.bordboek-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
}

.bordboek-action-btn.secondary {
    background: white;
    color: #44403c;
    border: 1px solid #e7e5e4;
    box-shadow: 0 2px 8px rgba(40, 30, 20, 0.05);
}

.bordboek-action-btn.secondary:hover {
    background: #f5f5f4;
    border-color: #d6d3d1;
}

.bordboek-action-btn i {
    width: 20px;
    height: 20px;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid #e7e5e4;
    z-index: 2100;
    min-width: 180px;
    overflow: hidden;
    animation: contextMenuFadeIn 0.15s ease-out;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #44403c;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.1s;
    text-align: left;
}

.context-menu-item:hover {
    background: #f5f5f4;
}

.context-menu-item.danger {
    color: #dc2626;
}

.context-menu-item.danger:hover {
    background: #fef2f2;
}

.context-menu-item i {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.context-menu-divider {
    height: 1px;
    background: #e7e5e4;
    margin: 0.25rem 0;
}

/* Empty State */
.bordboek-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 4px 15px -3px rgba(40, 30, 20, 0.08);
}

.bordboek-empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0d9488;
}

.bordboek-empty-icon i {
    width: 40px;
    height: 40px;
}

.bordboek-empty h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #292524;
    margin-bottom: 0.5rem;
}

.bordboek-empty p {
    color: #78716c;
    font-size: 0.875rem;
    max-width: 300px;
    margin: 0 auto;
}

/* Loading State */
.bordboek-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    gap: 1rem;
}

.bordboek-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e7e5e4;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Card hover actions */
.bordboek-card-actions {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.bordboek-card:hover .bordboek-card-actions {
    opacity: 1;
}

.bordboek-card-action {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 0.5rem;
    color: #78716c;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bordboek-card-action:hover {
    background: #f5f5f4;
    color: #292524;
}

.bordboek-card-action i {
    width: 16px;
    height: 16px;
}

/* Bordboek Filter Bar */
.bordboek-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 2px 10px -2px rgba(40, 30, 20, 0.06);
    gap: 1rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .bordboek-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .bordboek-filter-bar > div:first-child input {
        width: 100%;
    }
    .bordboek-filter-bar > div:last-child {
        justify-content: space-between;
    }
}

/* Widget Responsive */
.widget-toggle-btn {
    display: none;
}

@media (max-width: 1024px) {
    .widget-toggle-btn {
        display: flex;
    }
    #widgets-panel {
        display: none;
    }
    #widgets-panel.widgets-visible {
        display: flex;
        top: 76px;
        right: 6px;
        flex-direction: row;
        gap: 0.5rem;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        padding: 0.5rem;
        border-radius: 1rem;
        box-shadow: 0 10px 40px -10px rgba(40, 30, 20, 0.15);
    }
    #widgets-panel.widgets-visible button {
        margin-bottom: 0;
    }
    .widget-box {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%);
        z-index: 100;
    }
}

@media (min-width: 1025px) {
    .widget-toggle-btn {
        display: none !important;
    }
    #widgets-panel {
        display: flex !important;
    }
}

