/**
 * File: assets/css/style.css
 * Giao diện App cao cấp Mr Khang AI - Phiên bản 1.1.0
 * Tối ưu hóa UI/UX cho công tác tham mưu, tổng hợp khối Đảng.
 */

/* ==========================================================================
   1. RESET & FULL-SCREEN (Cách ly tuyệt đối khỏi Theme WordPress)
   ========================================================================== */
.mk-fullscreen-app, .mk-fullscreen-app * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#mrkhang-workspace {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483647 !important; /* Mức Z-index cao nhất để đè lên mọi Theme */
    background-color: #f1f5f9;
    display: flex;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ẩn thanh Admin Bar của WordPress nếu cán bộ đang đăng nhập */
body.admin-bar #wpadminbar { display: none !important; }

/* Tùy chỉnh thanh cuộn (Scrollbar) cho toàn bộ App */
.mk-fullscreen-app ::-webkit-scrollbar { width: 6px; height: 6px; }
.mk-fullscreen-app ::-webkit-scrollbar-track { background: transparent; }
.mk-fullscreen-app ::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }
.mk-fullscreen-app ::-webkit-scrollbar-thumb:hover { background-color: #94a3b8; }

/* ==========================================================================
   2. SIDEBAR CÔNG CỤ (Cột bên trái)
   ========================================================================== */
.mk-sidebar {
    width: 340px;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-shadow: 1px 0 15px rgba(0, 0, 0, 0.03);
    z-index: 20;
}

.mk-brand-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mk-logo-icon {
    font-size: 32px;
    background: #fef2f2;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(185, 28, 28, 0.1);
}

.mk-app-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #b91c1c; /* Đỏ sẫm trang trọng */
    letter-spacing: -0.5px;
}

.mk-app-subtitle { font-size: 12px; color: #64748b; font-weight: 600; display: block;}

.mk-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.mk-sidebar-section { margin-bottom: 25px; }

.mk-section-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
}

.mk-section-desc { font-size: 12px; color: #64748b; margin: 0 0 12px 0; line-height: 1.5; }

/* ==========================================================================
   3. CÁC FORM NHẬP LIỆU BÊN SIDEBAR (Cơ quan, Thể loại, Tệp đính kèm)
   ========================================================================== */
.mk-label {
    display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 6px;
}

.mk-input, .mk-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    color: #1e293b;
    transition: all 0.2s;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.mk-input:focus, .mk-select:focus {
    outline: none;
    border-color: #b91c1c;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}

textarea.mk-input { resize: vertical; min-height: 60px; line-height: 1.5; }

/* Khu vực tải File */
.mk-file-upload-wrapper {
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 20px 10px;
    text-align: center;
    background-color: #f8fafc;
    transition: 0.2s ease;
    cursor: pointer;
}
.mk-file-upload-wrapper:hover { border-color: #b91c1c; background-color: #fef2f2; }
#mk-file-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.mk-upload-placeholder { font-size: 13px; color: #475569; font-weight: 500; pointer-events: none; }
.mk-status-text { font-size: 12px; color: #059669; margin-top: 8px; font-weight: 600; text-align: center; }

/* Danh sách file đã tải */
.mk-file-list { list-style: none; padding: 0; margin: 12px 0 0 0; font-size: 12px; color: #475569; }
.mk-file-list li { 
    padding: 8px 12px; 
    border: 1px solid #e2e8f0; 
    border-radius: 6px;
    background: #f8fafc;
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 8px;
}

/* Quy chuẩn dạng Checkbox (Sticks) */
.mk-options-list { display: flex; flex-direction: column; gap: 10px; }
.mk-checkbox-label {
    display: flex; align-items: flex-start; cursor: pointer;
    background: #f8fafc; padding: 10px; border-radius: 6px;
    border: 1px solid transparent; transition: 0.2s;
}
.mk-checkbox-label:hover { border-color: #e2e8f0; background: #fff; }
.mk-option-checkbox { margin-top: 2px; margin-right: 10px; accent-color: #b91c1c; width: 16px; height: 16px; cursor: pointer;}
.mk-checkbox-text { font-size: 13px; color: #334155; line-height: 1.4; }

.mk-sidebar-bottom { padding: 20px; background-color: #ffffff; border-top: 1px solid #e2e8f0; }

/* ==========================================================================
   4. KHÔNG GIAN LÀM VIỆC CHÍNH (Cột phải - Bàn làm việc & Tờ giấy)
   ========================================================================== */
.mk-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #e2e8f0; /* Màu xám công sở */
    height: 100vh;
}

.mk-top-toolbar {
    height: 64px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 10;
}
.mk-doc-status { font-size: 14px; color: #475569; font-weight: 600; display: flex; align-items: center; gap: 8px;}

/* ==========================================================================
   4.1. GIAO DIỆN MAGIC AI TOOLBAR (Cụm xử lý đoạn văn bôi đen)
   ========================================================================== */
.mk-ai-toolbar-group {
    display: flex;
    align-items: center;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.mk-ai-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    padding: 0 12px 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mk-ai-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #475569;
    border: none;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mk-ai-btn:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.mk-ai-divider {
    width: 1px;
    height: 20px;
    background-color: #cbd5e1;
    margin: 0 8px;
}

.mk-ai-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    color: #ffffff;
    border: none;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(185, 28, 28, 0.2);
}

.mk-ai-btn-primary:hover {
    background: linear-gradient(135deg, #991b1b 0%, #b91c1c 100%);
    box-shadow: 0 4px 6px rgba(185, 28, 28, 0.3);
    transform: translateY(-1px);
}

.mk-ai-btn-primary:active {
    transform: translateY(0);
}

/* ==========================================================================
   4.2. TRANG GIẤY ĐIỆN TỬ (Editor)
   ========================================================================== */
.mk-editor-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px;
}

/* Tờ giấy A4 */
#mk-editor-container {
    width: 210mm; /* Chuẩn kích thước A4 */
    min-height: 297mm; /* Chuẩn kích thước A4 */
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 2px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05), 0 2px 5px rgba(0,0,0,0.03);
    border: 1px solid #cbd5e1;
}

/* Ghi đè giao diện mặc định của thư viện QuillJS */
.ql-container.ql-snow { border: none !important; }
.ql-editor {
    padding: 20mm 25mm !important; /* Lề trang giấy chuẩn hành chính Nghị định 30 */
    font-family: "Times New Roman", Times, serif;
    font-size: 14pt;
    line-height: 1.5;
    color: #000000;
}
.ql-editor p { margin-bottom: 12px; text-align: justify; }
.ql-editor h2, .ql-editor h3 { text-align: center; font-weight: bold; margin-top: 20px; margin-bottom: 15px; }

/* ==========================================================================
   5. KHU VỰC CHAT AI (Dưới cùng)
   ========================================================================== */
.mk-chat-panel {
    background-color: #ffffff;
    padding: 20px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.mk-chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 900px;
    margin: 0 auto;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 8px 8px 8px 20px;
    transition: 0.2s;
}
.mk-chat-input-wrapper:focus-within { border-color: #b91c1c; box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.05); background: #fff;}

.mk-prompt-textarea {
    flex: 1; height: 44px; padding: 10px 0; border: none; background: transparent;
    resize: none; font-size: 15px; color: #1e293b; outline: none; line-height: 1.5;
}

/* ==========================================================================
   6. CÁC NÚT BẤM CƠ BẢN (SIDEBAR & CHAT)
   ========================================================================== */
.mk-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; font-size: 13px; font-weight: 600; border-radius: 6px;
    cursor: pointer; transition: 0.2s; border: none; width: 100%; outline: none;
}
.mk-mt-2 { margin-top: 10px; }

.mk-btn-outline { background-color: #ffffff; color: #b91c1c; border: 1px solid #b91c1c; }
.mk-btn-outline:hover { background-color: #fef2f2; }

.mk-btn-export { background-color: #ffffff; border: 1px solid #cbd5e1; color: #475569; margin-bottom: 8px;}
.mk-btn-export:hover { background-color: #f8fafc; border-color: #94a3b8; color: #0f172a;}

.mk-btn-close { background-color: #fef2f2; color: #b91c1c; }
.mk-btn-close:hover { background-color: #fee2e2; }

.mk-btn-submit { background-color: #b91c1c; color: white; width: 44px; height: 44px; padding: 0; border-radius: 12px;}
.mk-btn-submit:hover { background-color: #991b1b; }
.mk-btn-submit:disabled { background-color: #cbd5e1; cursor: not-allowed; }

/* Loader Xoay (Chỉ hiện khi Submit API) */
.mk-loader { display: flex; align-items: center; justify-content: center; }
.mk-spinner { animation: rotate 2s linear infinite; z-index: 2; width: 20px; height: 20px; }
.mk-spinner .path { stroke: #ffffff; stroke-linecap: round; animation: dash 1.5s ease-in-out infinite; }

@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}