/* Project App - Full Screen Layout */

.project-app {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #f8fafc;
}

.desktop-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    height: calc(100vh - 60px);
    /* Account for header */
    overflow: hidden;
    padding: 1rem;
}

.sidebar,
.main-content {
    background-color: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar {
    min-height: 0;
}

.sidebar-header h3 {
    margin: 0 0 1rem 0;
    color: #374151;
    font-weight: 600;
    flex-shrink: 0;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.filter-btn {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background-color: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: #e2e8f0;
}

.filter-btn.active {
    background-color: #3b82f6;
    color: white;
}

.search-input {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    flex-shrink: 0;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.project-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    min-height: 0;
}

.project-item {
    padding: 0.75rem;
    padding-right: 2.5rem;
    /* Make room for pin icon */
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    position: relative;
    /* Ensure proper stacking */
    z-index: 1;
    /* Above any overlay issues */
    pointer-events: all;
    /* Explicitly enable pointer events */
}

.project-item:hover {
    background-color: #f8fafc;
    border-color: #e2e8f0;
}

.project-item.selected {
    background-color: #dbeafe;
    border-color: #3b82f6;
}

.project-name {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.project-status {
    font-size: 1rem;
    color: #64748b;
    letter-spacing: 0.02em;
}

.project-date {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

.new-project-btn {
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.export-btn {
    border: none;
    padding: 0.75rem 1.5rem;
    /* Match other action buttons */
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    flex-shrink: 0;
    /* No margin-bottom to align with save/delete buttons */
}

.new-project-btn {
    background-color: #10b981;
    color: white;
}

.new-project-btn:hover {
    background-color: #059669;
}

.export-btn {
    background-color: #64748b;
    color: white;
}

.export-btn:hover {
    background-color: #475569;
}

.main-content {
    min-height: 0;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #64748b;
}

.project-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Form Field Styles */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.editor-header {
    display: grid;
    /* 3 columns: name, status, category (uniform field widths) */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
    align-items: start;
}

.editor-header-compact {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.editor-header-compact .project-name-readonly {
    font-weight: 600;
    font-size: 1.1rem;
    color: #374151;
}

.editor-selection-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.editor-selection-line .project-name-readonly {
    font-weight: 600;
    font-size: 1rem;
    color: #374151;
}

.editor-selection-line .inline-name {
    flex: 1;
    max-width: 24rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 1rem;
}

.editor-vista-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding-top: 1.5rem;
    /* Align with inputs after label */
}

.project-title-input {
    flex: 1;
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
    min-width: 0;
}

.status-select {
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    font-size: 0.875rem;
    width: 100%;
    min-width: 0;
}

.subpage-name-row {
    margin-bottom: 1rem;
}

.subpage-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    margin-bottom: 1rem;
    /* Align the buttons with the textbox (not with the label) */
    align-items: end;
}

.subpage-bar .action-buttons {
    padding-top: 0;
    align-items: end;
}

.save-btn,
.delete-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: left;
    /* Ensure text aligns left if buttons are wide/flex */
    display: inline-flex;
    /* Use flex to align icon and text */
    align-items: center;
    justify-content: center;
    /* Center content horizontally */
    gap: 0.5rem;
    /* Space between icon and text */
}

.save-btn {
    background-color: #3b82f6;
    color: white;
}

.save-btn:hover:not(:disabled) {
    background-color: #2563eb;
}

.save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.delete-btn {
    background-color: #ef4444;
    color: white;
    justify-content: flex-start;
    /* Align content to the left */
    padding-left: 1rem;
    padding-right: 1rem;
}

.delete-btn:hover {
    background-color: #dc2626;
}

/* Pin Icon Button in Project List */
.pin-icon-btn-list {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: white;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: #000000;
    z-index: 10;
}

.pin-icon-btn-list:hover {
    background-color: #f3f4f6;
}

.pin-icon-list {
    width: 18px;
    height: 18px;
    color: #000000;
}

/* Rich Text Editor Styles */
.rte-custom {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.rte-custom .e-rte-toolbar {
    border-bottom: 2px solid #e2e8f0;
    background-color: #f8fafc;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.rte-custom .e-rte-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Mobile RTE optimizations */
@media (max-width: 768px) {
    .rte-custom .e-rte-toolbar {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .rte-custom .e-toolbar-item {
        padding: 0.25rem;
    }

    .rte-custom .e-tbar-btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

.rte-custom .e-rte-content .e-content {
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Markdown preview styling */
.rte-custom .e-md-preview {
    padding: 1rem;
}

.content-textarea {
    flex: 1;
    width: 100%;
    resize: none;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    background-color: #fafafa;
    min-height: 0;
}

.content-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background-color: white;
}

.timestamps {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #64748b;
    text-align: right;
    flex-shrink: 0;
}

.toc {
    min-height: 0;
}

.toc h4 {
    margin: 0;
    color: #374151;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-header {
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin: 0;
}

.toc-empty {
    font-size: 0.875rem;
    color: #9ca3af;
    font-style: italic;
}

.toc-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.toc-list li {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

.toc-list li:hover {
    background-color: #f1f5f9;
}

/* Smooth animations */
.project-item,
.filter-btn,
.action-buttons button {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Keyframes for animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Responsive Design for Desktop/Laptop */
@media (max-width: 1200px) {
    .app-layout {
        grid-template-columns: 240px 1fr;
    }
}

/* ===== Sidebar Tree (Syncfusion TreeView) ===== */
.tree-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.tree-title {
    font-weight: 600;
    color: #374151;
    margin-right: auto;
}

.tree-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.search-compact {
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

/* Make Syncfusion dropdowns compact in sidebar */
.compact-ddl {
    width: 100%;
}

/* TreeView container */
.project-treeview {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* prevent horizontal scrollbar */
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.25rem;
}

.tree-node-content {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
}

.tree-node-text {
    display: inline-block;
    flex: 1;
    min-width: 0;
}

.tree-node-attachment-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.tree-node-attachment-icon svg.hero-icon-paperclip {
    width: 1rem;
    height: 1rem;
    color: inherit;
}

/* Ensure long node text wraps instead of forcing horizontal scroll */
.project-treeview .e-list-text,
.project-treeview .e-list-item .e-text-content {
    white-space: normal;
    overflow-wrap: anywhere;
}

.tree-context-menu {
    position: fixed;
    z-index: 2000;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
    padding: 0.25rem;
    min-width: 160px;
}

.tree-context-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
}

.tree-context-item:hover:not(:disabled) {
    background: #f1f5f9;
}

.tree-context-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tree-context-item.danger {
    color: #b91c1c;
}

/* Attachments section (project root only) */
.attachments-section {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.attachments-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.attachment-add-btn {
    font-size: 0.875rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    background: #e2e8f0;
    color: #374151;
    cursor: pointer;
    border: 1px solid #cbd5e1;
}

.attachment-add-btn:hover {
    background: #cbd5e1;
}

.attachment-add-btn input[type="file"] {
    display: none;
}

/* Syncfusion uploader in attachments section - compact */
.attachments-header .attachment-uploader.e-upload {
    min-height: auto;
}

.attachments-header .e-upload .e-file-select-wrap {
    padding: 0.35rem 0.75rem;
}

/* Replace Syncfusion uploader drop hint "Or drop files here" with Icelandic */
.attachment-uploader .e-file-drop,
.attachment-uploader .e-upload-drag-hint,
.attachment-uploader .e-upload [class*="drop"],
.attachment-uploader .e-upload [class*="drag-hint"] {
    font-size: 0 !important;
    color: transparent !important;
}

.attachment-uploader .e-file-drop::after,
.attachment-uploader .e-upload-drag-hint::after,
.attachment-uploader .e-upload [class*="drop"]::after,
.attachment-uploader .e-upload [class*="drag-hint"]::after {
    content: "Eða dragðu skrár hingað";
    font-size: 0.875rem;
    color: #374151;
}

.attachments-empty {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
}

.attachments-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.875rem;
}

.attachment-link {
    color: #2563eb;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-link:hover {
    text-decoration: underline;
}

.attachment-meta {
    color: #64748b;
    flex-shrink: 0;
}

.attachment-delete {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.attachment-delete:hover {
    color: #ef4444;
}

/* Let Syncfusion theme control hover/selected colors (avoid double highlight). */

/* Admin Page Button Styles */
.equal-width-btn {
    width: 130px;
    text-align: center;
    justify-content: center;
    border: none;
    display: flex;
    align-items: center;
    border-radius: 0.375rem;
    background-color: rgb(229 231 235);
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    color: rgb(31 41 55);
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    background-color: rgb(209 213 219);
}

/* ==========================================================================
   Dark Mode Overrides
   Applied when .page has 'dark' class
   ========================================================================== */

.page.dark {
    background-color: #0f172a;
    /* slate-900 */
    color: #f1f5f9;
}

.page.dark .sidebar,
.page.dark .main-content,
.page.dark .toc {
    background-color: #1e293b;
    /* slate-800 */
    border: 1px solid #334155;
    color: #f1f5f9;
}

.page.dark .sidebar-header h3,
.page.dark .tree-title,
.page.dark .toc h4,
.page.dark .welcome-message h3 {
    color: #f8fafc;
}

.page.dark .welcome-message p {
    color: #94a3b8;
}

/* Inputs & Form Elements */
.page.dark .search-input,
.page.dark .project-title-input,
.page.dark .status-select,
.page.dark .compact-ddl,
.page.dark .e-input-group,
.page.dark input.e-input {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

.page.dark .field-label {
    color: #94a3b8;
}

/* Filter Buttons */
.page.dark .filter-btn {
    background-color: #334155;
    color: #94a3b8;
}

.page.dark .filter-btn:hover {
    background-color: #475569;
    color: #f1f5f9;
}

.page.dark .filter-btn.active {
    background-color: #3b82f6;
    /* blue-500 */
    color: white;
}

/* Project List Items */
.page.dark .project-item:hover {
    background-color: #334155;
    border-color: #475569;
}

.page.dark .project-item.selected {
    background-color: #1e3a8a;
    /* blue-900 */
    border-color: #3b82f6;
}

.page.dark .project-name {
    color: #f1f5f9;
}

.page.dark .project-status {
    color: #cbd5e1;
}

.page.dark .project-date {
    color: #64748b;
}

/* Rich Text Editor Overrides */
.page.dark .rte-custom {
    border-color: #475569;
}

.page.dark .rte-custom .e-rte-toolbar {
    background-color: #1e293b;
    border-bottom-color: #475569;
}

.page.dark .rte-custom .e-rte-content,
.page.dark .rte-custom .e-content {
    background-color: #0f172a;
    color: #e2e8f0;
}

.page.dark .rte-custom .e-toolbar-item button {
    color: #cbd5e1 !important;
}

.page.dark .rte-custom .e-toolbar-item button:hover {
    background-color: #334155 !important;
}

/* TreeView Overrides */
.page.dark .project-treeview {
    border-color: #475569;
    background-color: #1e293b;
    color: #f1f5f9;
}

.page.dark .e-treeview .e-list-text {
    color: #f1f5f9;
}

.page.dark .e-treeview .e-list-item.e-active>.e-fullrow,
.page.dark .e-treeview .e-list-item.e-hover>.e-fullrow {
    background-color: #334155;
    border-color: #475569;
}

/* Context Menu */
.page.dark .tree-context-menu {
    background-color: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.page.dark .tree-context-item:hover:not(:disabled) {
    background-color: #334155;
}

/* Scrollbars */
.page.dark ::-webkit-scrollbar-track {
    background: #1e293b;
}

.page.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.page.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.page.dark .glass {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}