/* Kyst Base Styles */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e1e4e8;
    --text-primary: #050505;
    --text-secondary: #4b4b4b;
    --accent: #2383e2;
    --accent-hover: #1e70c1;
    --border: #e1e4e8;
    --sidebar-width: 260px;
    --hub-sidebar-width: 72px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Selection */
::selection {
    background: var(--accent);
    color: white;
}

/* Global Layout */
.kyst-app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: transparent;
}

.app-background-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.3s ease, background-blend-mode 0.3s ease;
    pointer-events: none;
}

/* Utility classes */
.transition-opacity { transition: opacity 0.2s ease; }
.opacity-0 { opacity: 0; }
.group:hover .opacity-0 { opacity: 1; }
.relative { position: relative; }
.absolute { position: absolute; }
.flex { display: flex; }
.gap-1 { gap: 0.25rem; }
.p-1 { padding: 0.25rem; }
.z-10 { z-index: 10; }
.hidden { display: none; }

/* Block Controls Helper */
.edit-btn {
    background: #f7f7f7e6;
    border: 1px solid #e3e3e3;
    color: #2c2c2c;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.edit-btn:hover {
    background: var(--bg-tertiary);
}

.edit-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}



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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Resize handlers improvements */
.jspreadsheet thead td.resizable,
.jexcel thead td.resizable {
    pointer-events: auto !important;
    cursor: col-resize !important;
}

/* Ghost line for resizing */
.jss_resize_line,
.jexcel_resize_line,
.jspreadsheet .jss_resize_line,
.jexcel .jss_resize_line {
    background-color: var(--accent) !important;
    z-index: 99999 !important;
    display: block !important;
    position: absolute !important;
    pointer-events: none !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Specific feedback for row resize TR */
tr.resizing {
    background-color: rgba(35, 131, 226, 0.1) !important;
    box-shadow: inset 0 -2px 0 var(--accent) !important;
}

tr.resizing td {
    border-bottom: 2px solid var(--accent) !important;
}

/* Ensure the resize line has some volume if it's missing it */
.jss_resize_line:not([style*="width"]):not([style*="height"]) {
    width: 100% !important;
    height: 2px !important;
    left: 0 !important;
}




/* Base table appearance updates */
.jexcel {
    border-radius: 0 0 6px 6px !important;
    border-color: var(--border) !important;
    overflow: visible !important;
    /* Allow resize guides to be visible outside clipping */
}


.jexcel>thead>tr>td {
    background-color: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    padding: 8px 10px !important;
    border: 1px solid var(--border) !important;
    border-bottom: 2px solid var(--border) !important;
}

.jexcel>tbody>tr>td {
    border: 1px solid var(--border) !important;
    padding: 8px !important;
    font-size: 0.9rem !important;
    color: var(--text-primary) !important;
    background-color: var(--bg-primary);
}

/* Selected cells */
.jexcel>tbody>tr>td.highlight {
    background-color: rgba(35, 131, 226, 0.1) !important;
}

.jexcel>tbody>tr>td.highlight-selected {
    background-color: rgba(35, 131, 226, 0.2) !important;
    border-color: var(--accent) !important;
}

/* Row numbers (first column) */
.jspreadsheet tbody tr td:first-child,
.jexcel>tbody>tr>td:first-child {
    background-color: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
    font-size: 0.8rem !important;
    text-align: center;
    cursor: default !important;
    /* Evita mostrar o cursor de resize em toda a célula */
    position: relative;
}

/* Context Menu */
.jexcel_contextmenu {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border-radius: 6px !important;
    padding: 4px 0 !important;
    z-index: 1000 !important;
}

.jexcel_contextmenu>div {
    padding: 8px 16px !important;
    color: var(--text-primary) !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
}

.jexcel_contextmenu>div:hover {
    background: var(--bg-secondary) !important;
    color: var(--accent) !important;
}

.jexcel_contextmenu hr {
    border: 0 !important;
    border-top: 1px solid var(--border) !important;
    margin: 4px 0 !important;
}

/* Block Component Styles - Modularized */
/* See src/components/block_components/ for specific styles */

.block-container {
    position: relative;
    width: 100%;
}

.drag-target {
    border: 2px solid var(--accent) !important;
    background: rgba(35, 131, 226, 0.05) !important;
    box-shadow: 0 0 15px rgba(35, 131, 226, 0.1) inset !important;
    transform: scale(1.002);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

.top-0 {
    top: 0;
}

.right-0 {
    right: 0;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 8px;
}

.z-10 {
    z-index: 10;
}

.opacity-0 {
    opacity: 0;
}

.transition-opacity {
    transition: opacity 0.2s;
}

.group:hover .group-hover\:opacity-100 {
    opacity: 1;
}

.rounded {
    border-radius: 0.25rem;
}

.text-xs {
    font-size: 0.75rem;
}

.bg-gray-700 {
    background-color: #374151;
}

.border-gray-600 {
    border-color: #4b5563;
}

.text-white {
    color: white;
}

.px-1 {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.border {
    border-width: 1px;
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.hover\:bg-gray-600:hover {
    background-color: #4b5563;
}

.block-code-view code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    padding: 0;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
}

.block-code-view {
    padding: 1em;
    margin: 0;
    border-radius: 6px;
    overflow-x: auto;
}

.block-code-view pre {
    margin: 0;
    padding: 0;
}

.cursor-pointer {
    cursor: pointer;
}

.block:hover {
    background: rgba(0, 0, 0, 0.03);
}

.block.focused {
    background: rgba(0, 0, 0, 0.05);
}

.block:empty::before {
    content: "Type '/' for commands...";
    color: var(--text-secondary);
    opacity: 0.4;
    pointer-events: none;
}

.block-paragraph {
    font-size: 1rem;
}

.block-h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 1.5em 0 0.5em 0;
}

.block-h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1.25em 0 0.4em 0;
}

.block-h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1em 0 0.3em 0;
}

.block-bullet {
    padding-left: 24px;
    list-style-type: disc;
    /* Native bullets for <li> */
}

/* Remove ::before since we use <ul><li>...</li></ul> now */

.block-numbered {
    padding-left: 24px;
    list-style-type: decimal;
    /* Native numbers for <ol><li>...</li></ol> */
}


.block-quote {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    color: var(--text-secondary);
    font-style: italic;
}

.block-code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: #f8f9fa;
    color: #333333;
    padding: 12px 16px;
    border: 1px solid rgba(35, 131, 226, 0.4);
    border-radius: 6px;
    font-size: 0.9rem;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    overflow-x: auto;
}

.block-code-textarea {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: #f8f9fa;
    color: #333333;
    padding: 12px 16px;
    border: 1px solid rgba(35, 131, 226, 0.4);
    border-radius: 6px;
    font-size: 0.9rem;
    width: 100%;
    min-height: 150px;
    resize: vertical;
    white-space: pre;
    overflow-wrap: normal;
    tab-size: 4;
    outline: none;
}

.block-code-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.2);
}

/* Table block styles */
.table-block-container {
    margin: 8px 0;
    position: relative;
    outline: none;
}

.table-header {
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px;
}

.table-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.table-separator {
    color: var(--border);
    user-select: none;
}

.table-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.table-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.table-btn-danger:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.table-color-picker {
    width: 28px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}

.editable-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    table-layout: fixed;
}

.table-td {
    border: 1px solid var(--border);
    padding: 0;
    min-width: 60px;
    vertical-align: top;
    resize: horizontal;
    overflow: auto;
}

.table-td.selected {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.table-cell {
    padding: 8px 12px;
    min-height: 1.5em;
    outline: none;
    cursor: text;
    width: 100%;
}

.table-cell:focus {
    background: rgba(35, 131, 226, 0.05);
}

.table-cell:empty::before {
    content: "...";
    color: var(--text-secondary);
    opacity: 0.3;
}

.table-cell[contenteditable="false"] {
    cursor: default;
}

.table-wrapper {
    min-height: 100px;
}

/* Image & Divider Styles */
.hidden {
    display: none !important;
}

.divider-block {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2em 0;
    width: 100%;
}

.image-block {
    transition: transform 0.2s ease-out;
}

.image-container {
    user-select: none;
}

.image-container img {
    display: block;
    -webkit-user-drag: none;
}

.cursor-nwse-resize {
    cursor: nwse-resize;
}

.cursor-nesw-resize {
    cursor: nesw-resize;
}

.drag-target {
    border: 2px solid var(--accent) !important;
    background: rgba(35, 131, 226, 0.05) !important;
    box-shadow: 0 0 15px rgba(35, 131, 226, 0.1) inset !important;
    transform: scale(1.002);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(35, 131, 226, 0.1);
    border-top: 3px solid var(--accent);
    border-right: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.anim-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.98);
    }
}


.bg-blue-500 {
    background-color: #3b82f6;
}

.w-3 {
    width: 0.75rem;
}

.h-3 {
    height: 0.75rem;
}

.bottom-1 {
    bottom: 0.25rem;
}

.right-1 {
    right: 0.25rem;
}

.left-1 {
    left: 0.25rem;
}

.rounded-sm {
    border-radius: 0.125rem;
}

.border-2 {
    border-width: 2px;
}

.border-transparent {
    border-color: transparent;
}

.group-hover\:border-blue-400:hover,
.group:hover .group-hover\:border-blue-400 {
    border-color: #60a5fa !important;
}

/* Explicit Image Handle Styles */
.image-container:hover .opacity-0 {
    opacity: 1 !important;
}

.image-container .bg-blue-500 {
    z-index: 50 !important;
    pointer-events: auto !important;
}

/* More Utility Classes */
.justify-center {
    justify-content: center;
}

.justify-start {
    justify-content: flex-start;
}

.justify-end {
    justify-content: flex-end;
}

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

.gap-1 {
    gap: 4px;
}

.w-full {
    width: 100%;
}

.h-auto {
    height: auto;
}

.top-2 {
    top: 0.5rem;
}

.left-1\/2 {
    left: 50%;
}

.-translate-x-1\/2 {
    transform: translateX(-50%) !important;
}

.bg-gray-800\/90 {
    background-color: rgba(31, 41, 55, 0.9);
}

.p-1\.5 {
    padding: 0.375rem;
}

.rounded-lg {
    border-radius: 0.5rem;
}

.backdrop-blur-md {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.scale-95 {
    transform: scale(0.95);
}

.group:hover .group-hover\:scale-100 {
    transform: scale(1) !important;
}

.shadow-xl {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.border-white\/10 {
    border-color: rgba(255, 255, 255, 0.1);
}

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

.hover\:bg-white\/20:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.pointer-events-auto {
    pointer-events: auto;
}

.inline-block {
    display: inline-block;
}

.shadow-md {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.z-20 {
    z-index: 20;
}


/* Dark theme adjustments for alerts */
[data-theme="dark"] .alert-info {
    color: #6ea8fe;
    background-color: #031633;
    border-color: #084298;
}

[data-theme="dark"] .alert-warning {
    color: #ffda6a;
    background-color: #332701;
    border-color: #664d03;
}

[data-theme="dark"] .alert-danger {
    color: #ea868f;
    background-color: #2c0b0e;
    border-color: #842029;
}

[data-theme="dark"] .alert-success {
    color: #75b798;
    background-color: #051b11;
    border-color: #0f5132;
}

