/* Base Styles */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #334155;
    background: #f8fafc;
}

/* Typography */
h1, h2, h3, h4 { margin: 0; color: #0f172a; }
p { line-height: 1.5; color: #475569; }

/* Left Nav Layout */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.left-nav {
    width: 250px;
    background: #1e293b;
    color: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 20px;
    color: #fff;
    border-bottom: 1px solid #334155;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav-close { display: none; cursor: pointer; font-size: 20px; }
.nav-links {
    display: flex;
    flex-direction: column;
    padding: 10px;
}
.nav-links a {
    text-decoration: none;
    color: #cbd5e1;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 5px;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
    background: #334155;
    color: #fff;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: #f8fafc;
}

/* Dashboard */
.view-dashboard {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.empty-state-box {
    margin-top: 30px; 
    padding: 20px; 
    background: #f8fafc; 
    border-radius: 8px; 
    border: 1px dashed #cbd5e1;
    text-align: center;
}

/* Knowledge Hub Headers */
.knowledge-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fdfdfd;
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.knowledge-table-wrapper {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.knowledge-table {
    width: 100%;
    border-collapse: collapse;
}
.knowledge-table th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    font-size: 12px;
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    text-transform: uppercase;
}
.knowledge-table td {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 14px;
    vertical-align: middle;
}
.category-row {
    background: #f8fafc;
}
.category-row td {
    color: #0f172a;
}
.document-row:hover {
    background: #f1f5f9;
}
.doc-link {
    cursor: pointer;
    transition: color 0.15s;
}
.doc-link:hover {
    color: #3b82f6; 
}


/* Category Actions Dropdown */
.actions-dropdown {
    position: relative;
    display: inline-block;
}
.actions-dropdown-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 10px;
    border-radius: 4px;
}
.actions-dropdown-btn:hover {
    background: #e2e8f0;
    color: #334155;
}
.actions-dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 8px;
    min-width: 160px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 5px 0;
}
.actions-dropdown-menu button {
    background: transparent;
    border: none;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    width: 100%;
    transition: background 0.15s;
}
.actions-dropdown-menu button:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* View transitions */
.fade-in { animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Buttons */
.btn-primary {
    background: #3b82f6; color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 13px;
}
.btn-primary:hover { background: #2563eb; }

.btn-outline {
    background: transparent; color: #475569; border: 1px solid #cbd5e1; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; text-decoration: none;
}
.btn-outline:hover { background: #f1f5f9; border-color: #94a3b8; }

.btn-open {
    background: #f1f5f9; color: #334155; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; text-align: center;
}
.btn-open:hover { background: #e2e8f0; }

.btn-danger {
    background: #fee2e2; color: #b91c1c; border: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; margin-left: auto;
}
.btn-danger:hover { background: #fca5a5; }

/* Modal */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(2px);
}
.modal-content {
    background: #ffffff; padding: 30px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.modal-content h3 { margin-bottom: 20px; font-size: 18px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 6px; }
.form-group input, .form-group select {
    width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; box-sizing: border-box; font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; }

/* -------------------------------------
 * Editor Integrated Styles
 * ------------------------------------- */
.sentinel-app-wrapper { 
    display: flex; height: calc(100vh - 170px); overflow: hidden; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.column-panel { display: flex; flex-direction: column; background: #ffffff; border-right: 1px solid #e0e0e4; }
.column-panel:last-child { border-right: none; }
.panel-header {
    padding: 15px 20px; background: #f1f5f9; border-bottom: 1px solid #e0e0e4;
    font-weight: 600; font-size: 13px; color: #666; text-transform: uppercase; letter-spacing: 0.5px;
    flex-shrink: 0; display: flex; justify-content: space-between; align-items: center;
}
.scroll-container { flex: 1; overflow-y: auto; padding: 30px; }

/* Outline List overrides */
#outline-list { list-style: none; padding: 0; margin: 0; }
#outline-list li { 
    cursor: pointer; 
    color: #3b82f6; 
    margin-bottom: 8px; 
    transition: color 0.15s; 
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
#outline-list li:hover { color: #1d4ed8; text-decoration: underline; }

/* Summernote Inner Styles */
.note-editor.note-airframe { border: none; }
.note-editable { outline: none !important; min-height: 100%; line-height: 1.6; }
.note-editable p { margin-bottom: 0.75em; line-height: 1.6; }
.note-editable h1 { font-size: 1.8em !important; margin-top: 1.2em; margin-bottom: 0.6em; font-weight: 700; color: #0f172a; }
.note-editable h2 { font-size: 1.4em !important; margin-top: 1em; margin-bottom: 0.5em; font-weight: 600; color: #1e293b; }
.note-editable h3 { font-size: 1.15em !important; margin-top: 0.8em; margin-bottom: 0.4em; font-weight: 600; color: #334155; }
.note-editable h1 *, .note-editable h2 *, .note-editable h3 * { font-size: inherit !important; }

.note-editable ul, .note-editable ol { margin-bottom: 1em; padding-left: 2em; }
.note-editable li { margin-bottom: 0.5em; font-size: 1em; line-height: 1.5; }

#summary-editor-container .note-editable h1 { font-size: 1.3em !important; }
#summary-editor-container .note-editable h2 { font-size: 1.1em !important; }
#summary-editor-container .note-editable h3 { font-size: 0.95em !important; }

.zoom-controls button {
    background: transparent; border: 1px solid #cbd5e1; border-radius: 4px; color: #64748b;
    cursor: pointer; font-size: 14px; width: 24px; height: 24px; margin-left: 4px;
    display: inline-flex; align-items: center; justify-content: center; transition: background 0.2s, color 0.2s; padding: 0;
}
.zoom-controls button:hover { background: #e2e8f0; color: #0f172a; }

/* -------------------------------------
 * Tasks Section Styles
 * ------------------------------------- */
.task-form-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-top: 20px;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.category-panel {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.category-panel .panel-header {
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    text-transform: none;
    letter-spacing: normal;
}

.category-panel .panel-content {
    padding: 15px;
    flex: 1;
}

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

.task-item {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.task-item:last-child {
    margin-bottom: 0;
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
    min-height: 25px;
    width: 100%;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 22px;
    width: 22px;
    background-color: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: #3b82f6;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-text {
    color: #334155;
    transition: all 0.3s;
    line-height: 1.4;
}

.task-text.completed {
    text-decoration: line-through;
    color: #94a3b8;
}

.btn-icon.text-red {
    color: #ef4444;
}

.btn-icon.text-red:hover {
    background: #fee2e2;
}

/* Chat Drawer Styles */
.chat-drawer {
    position: fixed;
    bottom: 0px;
    left: 270px;
    /* 250px navbar + 20px margin */
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.1);
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 48px;
    border: 1px solid #e2e8f0;
    border-bottom: none;
}

.chat-drawer.is-open {
    height: 50vh;
}

.chat-body {
    height: calc(100% - 48px);
    background: white;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e2e8f0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto !important;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-input-area {
    padding: 12px 15px 15px 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
    align-items: center; /* Changed from flex-end to center to align button and text better */
    flex-shrink: 0;
}

.relative { position: relative; }
.view-editor { display: block; }

/* Typing Indicator Animation */
.typing-indicator span {
    height: 8px; width: 8px; float: left; margin: 0 1px;
    background-color: #94a3b8; display: block; border-radius: 50%;
    opacity: 0.4; animation: 1s blink infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.1s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.2s; }
@keyframes blink { 50% { opacity: 1; } }

/* Markdown Styles in Chat */
.markdown-content h1, .markdown-content h2, .markdown-content h3 { font-size: 1.1em; margin: 10px 0 5px 0; color: inherit; }
.markdown-content p { margin: 0 0 8px 0; }
.markdown-content ul, .markdown-content ol { margin: 5px 0 10px 20px; padding: 0; }
.markdown-content li { margin-bottom: 3px; }
.markdown-content code { background: rgba(0, 0, 0, 0.05); padding: 2px 4px; border-radius: 4px; font-family: monospace; }
.markdown-content pre { background: #1e293b; color: #f8fafc; padding: 10px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.markdown-content pre code { background: transparent; padding: 0; color: inherit; }
.markdown-content blockquote { border-left: 3px solid #cbd5e1; margin: 10px 0; padding-left: 10px; font-style: italic; color: #64748b; }

.modal-body {
    padding: 10px 0;
}

/* -------------------------------------
 * Responsive / Mobile Styles
 * ------------------------------------- */
.mobile-header {
    display: none;
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (max-width: 768px) {
    .mobile-header { display: flex; }
    
    .app-layout { flex-direction: column; }
    
    .left-nav {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 10px 0 30px rgba(0,0,0,0.3);
    }
    
    .left-nav.is-open { left: 0; }
    
    .nav-close { display: block; }

    .main-content {
        padding: 20px;
        width: 100%;
        box-sizing: border-box;
    }

    .knowledge-toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .toolbar-right {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .toolbar-right button { flex: 1; }

    /* Forms on mobile */
    .task-form-card div {
        grid-template-columns: 1fr !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Editor on mobile */
    .sentinel-app-wrapper {
        flex-direction: column;
        height: auto;
    }

    .column-panel {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        height: 50vh;
    }

    aside.column-panel[style*="width: 250px"] {
        height: 200px;
    }

    /* Chat on mobile */
    .chat-drawer {
        left: 10px;
        right: 10px;
    }
    
    .chat-drawer.is-open {
        height: 85vh;
    }

    /* Tables on mobile: scrollable */
    .knowledge-table-wrapper {
        overflow-x: auto;
    }
}

/* Belongings specific */
.belonging-img-preview {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}
.image-upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: #fff;
}
.image-upload-zone:hover { border-color: #3b82f6; background: #f8fafc; }
.image-preview-large {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 6px;
    margin-top: 10px;
}
.badge-location {
    background: #f1f5f9 !important;
    color: #475569 !important;
    padding: 2px 8px !important;
    border-radius: 99px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    display: inline-block;
}
