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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 250px;
    background: #1a1a1a;
    border-right: 1px solid #333;
    padding: 20px;
    overflow-y: auto;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 50px;
    padding: 10px 0px;
}

.sidebar.collapsed .logo,
.sidebar.collapsed .search-container,
.sidebar.collapsed .nav-item,
.sidebar.collapsed .data-controls {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logout-btn {
    margin-top: 8px;
}
.logo {
    font-size: 18px;
    font-weight: bold;
    color: #00d5ffd8;
}

.sidebar-toggle {
    background: #333;
    border: none;
    color: #e0e0e0;
    padding: 8px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: #444;
}

.search-container {
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    margin-bottom: 8px;
}

.search-input:focus {
    border-color: #00d5ffd8;
    background: #2a2a2a;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    display: none;
}

.search-result-group {
    border-bottom: 1px solid #333;
}

.search-result-group:last-child {
    border-bottom: none;
}

.search-result-canvas-title {
    padding: 8px 16px;
    background: #252525;
    color: #00d5ffd8;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:hover {
    background: #252525;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 600;
    color: #00d5ffd8;
    margin-bottom: 4px;
}

.search-result-context {
    font-size: 12px;
    color: #999;
}

.search-result-type {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    margin-top: 4px;
}

.nav-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: #252525;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #2a2a2a;
    border-left-color: #00d5ffd8;
}

.nav-item.active {
    background: #2a2a2a;
    border-left-color: #00d5ffd8;
    color: #00d5ffd8;
}

.nav-item.drag-over {
    background: rgba(0, 212, 255, 0.4);
    border-color: #00d5ffd8;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
    animation: pulse-blue 1.5s infinite;
}

.canvas-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.canvas {
    min-width: 100%;
    min-height: 100%;
    padding: 40px;
}

.canvas-title {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 30px;
    color: #00d5ffd8;
}

.module {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 9px;
    margin-bottom: 7px;
    cursor: pointer;
    transition: all 0.2s;
}

.module:hover {
    border-color: #555;
}

.module.selected {
    border: 2px solid #00d5ffd8 !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4) !important;
}

.module.drag-over {
    border: 3px solid #00d5ffd8;
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.8);
    background: rgba(0, 212, 255, 0.1);
    transform: scale(1.02);
    animation: pulse-blue 1.5s infinite;
}

.module.dragging {
    opacity: 0.3;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border: 2px solid #00d5ffd8 !important;
}

.module-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    margin-bottom: 7px;
    gap: 8px;
}

.module-header .module-title {
    justify-self: start;
}

.module-header .open-module-btn {
    justify-self: center;
}

.module-header .delete-btn {
    justify-self: end;
}

.module-title {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    outline: none;
    cursor: text;
}

.module-title:focus {
    background: rgba(0, 212, 255, 0.1);
    border-radius: 4px;
    padding: 2px 4px;
}

.module-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    padding: 6px 12px;
    background: #333;
    border: none;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn:hover {
    background: #444;
}

.emoji-only {
    padding: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.delete-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 20;
}

.delete-overlay:hover {
    opacity: 1;
    background: rgba(220, 53, 69, 0.9);
}

.selectable-table {
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.selectable-table:hover {
    border-color: rgba(0, 212, 255, 0.3);
}

.selectable-table.selected {
    border-color: #00d5ffd8;
    background: rgba(0, 212, 255, 0.05);
}

.selectable-table.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.table-delete-btn {
    display: none;
    opacity: 0.8;
}

.selectable-table.selected .table-delete-btn {
    display: block;
}

.btn-primary {
    background: #00d5ffd8;
    color: #0a0a0a;
}

.btn-primary:hover {
    background: #00b8e6;
}

.content-editable {
    min-height: 60px;
    padding: 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    outline: none;
    line-height: 1.6;
}

.content-editable:focus {
    border-color: #00d5ffd8;
    background: #2a2a2a;
}

.content-editable[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #666;
}

.content-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.type-btn {
    padding: 6px 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.type-btn:hover, .type-btn.active {
    color: #ffffff;
    border-color: white;
    background: #00d5ff9f;
    font-weight: bold;
;
}

.type-btn.has-elements {
    border: 1px solid #00d5ffd8;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    table-layout: fixed;
}

th, td {
    padding: 10px;
    text-align: left;
    border: 1px solid #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    position: relative;
}

th {
    background: #252525;
    font-weight: 600;
}

td {
    background: #1a1a1a;
}

td[contenteditable="true"] {
    cursor: text;
}

td[contenteditable="true"]:focus {
    background: #2a2a2a;
    outline: 2px solid #00d5ffd8;
}

td.selected, th.selected {
    background: rgba(0, 212, 255, 0.2) !important;
    border-color: #00d5ffd8;
}

.resizer {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: rgba(0, 212, 255, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
}

.resizer:hover {
    opacity: 1;
}

.table-block {
    position: relative;
    overflow: hidden;
}

.link-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
}

.link-item a,
.document-item a {
    flex: 1;
    color: #ff6b35;
    text-decoration: none;
}

.link-item a:hover {
    text-decoration: underline;
}

.link-item button {
    padding: 4px 8px;
    font-size: 11px;
}

.link-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.image-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #252525;
    border: 1px solid #333;
}

.image-item img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    display: block;
}

.image-item .delete-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
}

.image-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.audio-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audio-item {
    padding: 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
}

.audio-item audio {
    width: 100%;
    margin-top: 8px;
}

.audio-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.file-input-wrapper {
    margin-top: 12px;
}

.file-input-label {
    display: inline-block;
    padding: 8px 16px;
    background: #333;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.file-input-label:hover {
    background: #444;
}

.file-input-label.framed {
    background: transparent;
    color: #00d5ffd8;
    border: 2px solid #00d5ffd8;
}

.file-input-label.framed:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: #00b8e6;
}

input[type="file"] {
    display: none;
}

.overview-map {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 30px;
}

.canvas-node {
    background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
    border: 2px solid #333;
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.canvas-node:hover {
    border-color: #00d5ffd8;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 212, 255, 0.2);
}

.canvas-node h3 {
    color: #00d5ffd8;
    margin-bottom: 12px;
}

.canvas-node p {
    color: #999;
    font-size: 14px;
    line-height: 1.6;
}

.connections {
    margin-top: 40px;
    padding: 24px;
    background: #1a1a1a;
    border-radius: 12px;
    border: 1px solid #333;
}

.connection-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: #252525;
    border-radius: 8px;
    font-size: 14px;
}

.connection-arrow {
    margin: 0 12px;
    color: #00d5ffd8;
}

.add-module-btn {
    width: 100%;
    padding: 16px;
    margin-top: 24px;
    background: #252525;
    border: 2px dashed #333;
    border-radius: 12px;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.add-module-btn:hover {
    border-color: #00d5ffd8;
    color: #00d5ffd8;
    background: #1a1a1a;
}

.relation-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #333;
    border-radius: 12px;
    font-size: 11px;
    color: #00d5ffd8;
    margin: 4px;
}

.module-footer {
    padding: 12px;
    border-top: 1px solid #333;
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.add-row-btn, .add-column-btn {
    margin-top: 8px;
    width: calc(50% - 4px);
}

.table-controls {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.link-input-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.link-input-group input {
    flex: 1;
    padding: 8px 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    outline: none;
}

.link-input-group input:focus {
    border-color: #00d5ffd8;
}

.open-module-btn {
    background: #00d5ffd8;
    color: #0a0a0a;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: normal;
    transition: all 0.2s;
}

.open-module-btn:hover {
    background: #00b8e6;
}

.text-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.text-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #252525;
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.text-item:hover {
    border-color: #00d5ffd8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.2);
}

/* Dragging states for all element types */
.text-item.dragging,
.table-block.dragging,
.link-item.dragging,
.image-item.dragging,
.audio-item.dragging,
.video-item.dragging,
.document-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    border: 2px solid #00d5ffd8 !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4) !important;
}

/* Individual dragging states for consistency */
.selectable-table.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    border: 2px solid #00d5ffd8 !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4) !important;
}

.text-title-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #333;
    color: #00d5ffd8;
    padding: 4px 12px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.text-preview {
    padding: 12px;
    flex: 1;
    color: #e0e0e0;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    margin-top: 40px; /* Space for title overlay */
}

.text-title-preview {
    color: #00d5ffd8;
}

.text-item .delete-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
}

.video-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border: 2px solid #00d5ffd8 !important;
}

.document-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border: 2px solid #00d5ffd8 !important;
}

.delete-block-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    font-size: 11px;
}

.add-text-btn {
    width: 100%;
    margin-bottom: 12px;
}

.tables-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 12px;
}

.table-block {
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 0;
    overflow: visible;
    max-width: 100%;
    position: relative;
}

.table-block table {
    min-width: 100%;
    transform-origin: top left;
    margin-bottom: 8px;
}

.table-block.scaled {
    overflow: visible;
}

.table-block.scaled table {
    transform-origin: top left;
}

.table-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.table-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.table-input-group textarea {
    background: #252525;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px;
    font-family: monospace;
    resize: vertical;
}

.data-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-delete-cell {
    width: 40px;
    min-width: 40px;
    padding: 0;
    text-align: center;
    position: relative;
}

.row-delete-cell .delete-row-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.7;
    transition: opacity 0.2s;
}

.row-delete-cell .delete-row-btn:hover {
    opacity: 1;
}

.editable-plain-text {
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    cursor: text;
    transition: background-color 0.2s;
}

.editable-plain-text:focus {
    background: rgba(0, 212, 255, 0.1);
    outline: none;
}

/* Drag and drop visual feedback animations */
@keyframes pulse-blue {
    0%, 100% {
        opacity: 1;
        transform: scale(0.95);
    }
    50% {
        opacity: 0.9;
        transform: scale(0.99);
    }
}

/* Show all valid drop targets during dragging */
.nav-item.drag-target {
    background: rgba(0, 212, 255, 0.75);
    border-left-color: #00d5ffd8;
    opacity: 0.8;
    animation: fade-in-blue 0.3s ease-in;
}

.module.drag-target {
    border: 2px solid rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 24px rgba(0, 212, 255, 0.5);
    background: rgba(0, 212, 255, 0.05);
    animation: fade-in-blue 0.2s ease-in, pulse-blue 1s infinite 0.2s;
}

@keyframes fade-in-blue {
    from {
        opacity: 0.5;
        transform: scale(0.95);
    }
    to {
        opacity: 0.75;
        transform: scale(0.99);
    }
}


@keyframes fade-in-blue {
    from {
        opacity: 0.5;
        transform: scale(0.95);
    }
    to {
        opacity: 0.75;
        transform: scale(0.99);
    }
}

/* Focus Mode Styles */
.focus-mode-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.focused-module-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    padding-top: 70px;
}

.modules-grid-sidebar {
    width: calc(100% / 6);
    min-width: 200px;
    background: #1a1a1a;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.modules-grid-sidebar.collapsed {
    width: 50px;
    min-width: 50px;
}

.modules-grid-sidebar.collapsed .grid-sidebar-content {
    display: none;
}

.modules-grid-sidebar.collapsed .grid-sidebar-header span {
    display: none;
}

.grid-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
    color: #00d4ff;
    font-weight: 600;
}

.grid-toggle {
    background: #333;
    border: none;
    color: #e0e0e0;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.grid-toggle:hover {
    background: #444;
}

.grid-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.module-mini-card {
    background: #252525;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.module-mini-card:hover {
    border-color: #00d4ff;
    background: #2a2a2a;
    transform: translateX(-4px);
}

.module-mini-card.active {
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}

.mini-card-title {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.mini-card-count {
    color: #00d4ff;
    font-size: 12px;
}