/* ==========================================================================
   FEATURE-037-A: Compose Idea Modal — Create New
   Follows stage-toolbox modal CSS pattern (z-index 1051)
   Design tokens: Slate palette, Emerald accent, DM Sans, 8px unit, 12px radius
   ========================================================================== */

/* --------------------------------------------------------------------------
   Overlay
   -------------------------------------------------------------------------- */
.compose-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1051;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
}

.compose-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* --------------------------------------------------------------------------
   Modal Dialog
   -------------------------------------------------------------------------- */
.compose-modal {
    background: #fff;
    border-radius: 12px;
    width: 80vw;
    height: 85vh;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.compose-modal-overlay.active .compose-modal {
    transform: scale(1) translateY(0);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.compose-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.compose-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.compose-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, background-color 0.2s;
}

.compose-modal-close:hover {
    color: #1e293b;
    background-color: #f1f5f9;
}

/* --------------------------------------------------------------------------
   Body (scrollable)
   -------------------------------------------------------------------------- */
.compose-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* --------------------------------------------------------------------------
   Mode Toggle (Create New / Link Existing)
   -------------------------------------------------------------------------- */
.compose-modal-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.compose-modal-toggle button {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.compose-modal-toggle button.active {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
}

.compose-modal-toggle button:hover:not(.active) {
    background: #f1f5f9;
    color: #334155;
}

/* --------------------------------------------------------------------------
   Name Input
   -------------------------------------------------------------------------- */
.compose-modal-name {
    margin-bottom: 16px;
}

.compose-modal-name label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.compose-modal-name input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    transition: border-color 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.compose-modal-name input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.compose-modal-name-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
}

.compose-modal-word-counter {
    color: #94a3b8;
}

.compose-modal-word-counter.over-limit {
    color: #ef4444;
    font-weight: 600;
}

.compose-modal-name-error {
    color: #ef4444;
    font-size: 12px;
}

.compose-modal-folder-preview {
    color: #94a3b8;
    font-size: 12px;
    margin-top: 2px;
    font-family: monospace;
}

/* --------------------------------------------------------------------------
   Tab Bar (Compose / Upload)
   -------------------------------------------------------------------------- */
.compose-modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.compose-modal-tabs button {
    padding: 8px 20px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.compose-modal-tabs button.active {
    color: #10b981;
    border-bottom-color: #10b981;
}

.compose-modal-tabs button:hover:not(.active) {
    color: #334155;
}

/* --------------------------------------------------------------------------
   Compose Tab — Editor Area
   -------------------------------------------------------------------------- */
.compose-modal-editor {
    min-height: 200px;
}

.compose-modal-editor .EasyMDEContainer {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.compose-modal-editor .EasyMDEContainer .CodeMirror {
    min-height: 180px;
    border: none;
    font-size: 14px;
}

.compose-modal-editor .editor-toolbar {
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

/* --------------------------------------------------------------------------
   Upload Tab — Drop Zone
   -------------------------------------------------------------------------- */
.compose-modal-upload {
    display: none;
}

.compose-modal-upload.active {
    display: block;
}

.compose-modal-dropzone {
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}

.compose-modal-dropzone:hover,
.compose-modal-dropzone.dragover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
    color: #10b981;
}

.compose-modal-dropzone.uploading {
    pointer-events: none;
    opacity: 0.6;
}

.compose-modal-dropzone-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.compose-modal-dropzone-text {
    font-size: 14px;
    margin-bottom: 4px;
}

.compose-modal-dropzone-hint {
    font-size: 12px;
    color: #94a3b8;
}

/* File list */
.compose-modal-file-list {
    margin-top: 12px;
}

.compose-modal-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 13px;
}

.compose-modal-file-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
}

.compose-modal-file-item-size {
    color: #94a3b8;
    font-size: 12px;
}

.compose-modal-file-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.compose-modal-file-remove:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* --------------------------------------------------------------------------
   Placeholder (Link Existing mode)
   -------------------------------------------------------------------------- */
.compose-modal-placeholder {
    text-align: center;
    padding: 48px 24px;
    color: #94a3b8;
}

.compose-modal-placeholder i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.compose-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
}

.compose-modal-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    font-family: inherit;
}

.compose-modal-btn-cancel {
    background: #fff;
    color: #64748b;
    border-color: #e2e8f0;
}

.compose-modal-btn-cancel:hover {
    background: #f1f5f9;
    color: #334155;
}

.compose-modal-btn-submit {
    background: #10b981;
    color: #fff;
}

.compose-modal-btn-submit:hover:not(:disabled) {
    background: #059669;
}

.compose-modal-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Error Toast (inline)
   -------------------------------------------------------------------------- */
.compose-modal-toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 12px;
    display: none;
}

.compose-modal-toast.error {
    display: block;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.compose-modal-toast.success {
    display: block;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* ==========================================================================
   FEATURE-037-B: Link Existing Panel
   ========================================================================== */

.link-existing-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.link-existing-search {
    padding: 0 0 4px;
}

.link-existing-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}

.link-existing-columns {
    display: flex;
    gap: 12px;
    min-height: 260px;
    flex: 1;
}

.link-existing-tree {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow-y: auto;
    max-height: 340px;
    background: #f8fafc;
}

.link-existing-preview {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow-y: auto;
    max-height: 340px;
    padding: 12px;
    background: #ffffff;
}

.link-existing-item {
    padding: 5px 8px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.link-existing-item:hover {
    background: #e0f2fe;
}

.link-existing-item.selected {
    background: #dbeafe;
    font-weight: 500;
}

.link-item-icon {
    flex-shrink: 0;
}

.link-existing-empty {
    color: #94a3b8;
    text-align: center;
    padding: 24px 12px;
    font-size: 13px;
}

.link-existing-preview-content {
    font-size: 13px;
    line-height: 1.6;
}
