/**
 * File: assets/css/style.css
 * Phiên bản: 3.0.0 - Giao diện Native HTML5, Accordion, Nút Refresh và Tối ưu hóa xuất PDF.
 * Phục vụ hệ sinh thái tham mưu LaDo-AI.
 */

/* ==========================================================================
   1. RESET & FULL-SCREEN (Cách ly tuyệt đối khỏi Theme)
   ========================================================================== */
.mk-fullscreen-app, .mk-fullscreen-app * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Đã đồng bộ ID với class-frontend.php */
#lado-workspace {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483646 !important; /* Mức Z-index siêu cao */
    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: #f0f9ff;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(3, 105, 161, 0.1);
}

.mk-app-title { margin: 0; font-size: 18px; font-weight: 800; color: #0369a1; 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; }

/* ==========================================================================
   3. CÁC FORM NHẬP LIỆU BÊN SIDEBAR
   ========================================================================== */
.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: #0369a1; box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.1); }
textarea.mk-input { resize: vertical; min-height: 60px; line-height: 1.5; }

/* Khối Accordion Đóng/Mở thông tin đơn vị */
.mk-accordion-wrapper {
    background-color: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; overflow: hidden;
}
.mk-accordion-header {
    padding: 15px; cursor: pointer; background: #fff; border-bottom: 1px solid #e2e8f0; transition: 0.2s;
}
.mk-accordion-header:hover { background: #f0f9ff; }
.mk-accordion-body { padding: 15px; display: none; }
.mk-toggle-icon.open { transform: rotate(180deg); }

/* Trình tải File tham chiếu */
.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: #0369a1; background-color: #f0f9ff; }
#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; }

/* 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 */
.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: #0369a1; 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 (Bàn làm việc & Toolbar)
   ========================================================================== */
.mk-main-area { flex: 1; display: flex; flex-direction: column; background-color: #e2e8f0; 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;}

/* Nút Refresh Làm mới văn bản */
.mk-btn-action-light {
    display: inline-flex; align-items: center; gap: 5px; background: #f0f9ff; color: #0369a1;
    border: 1px solid #bae6fd; padding: 6px 12px; border-radius: 6px; cursor: pointer;
    font-size: 13px; font-weight: 600; transition: 0.2s;
}
.mk-btn-action-light:hover { background: #e0f2fe; border-color: #7dd3fc; }

/* ==========================================================================
   4.1. MAGIC AI TOOLBAR (Khối xử lý đoạ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, #0369a1 0%, #0284c7 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(3, 105, 161, 0.2); }
.mk-ai-btn-primary:hover { background: linear-gradient(135deg, #075985 0%, #0369a1 100%); box-shadow: 0 4px 6px rgba(3, 105, 161, 0.3); transform: translateY(-1px); }

/* ==========================================================================
   4.2. TRANG GIẤY ĐIỆN TỬ & HIỆU ỨNG PROGRESS BAR (NATIVE HTML5)
   ========================================================================== */
.mk-editor-wrapper { flex: 1; overflow-y: auto; padding: 40px 20px; scroll-behavior: smooth; }

/* Thanh Progress Bar sọc chạy */
#mk-progress-bar { position: relative; overflow: hidden; }
#mk-progress-bar::after { content: ""; position: absolute; top: 0; left: 0; bottom: 0; right: 0; background-image: linear-gradient(-45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%, transparent); background-size: 50px 50px; animation: progress-shimmer 2s linear infinite; }
@keyframes progress-shimmer { 0% { background-position: 0 0; } 100% { background-position: 50px 50px; } }

/* Hiệu ứng hào quang khi AI đang gõ văn bản */
.mk-writing-active { box-shadow: 0 0 25px rgba(3, 105, 161, 0.15), 0 10px 25px rgba(0,0,0,0.05) !important; border: 1px solid #0369a1 !important; transition: all 0.5s ease; }

/* Tờ giấy A4 chuẩn Native */
.mk-native-editor {
    width: 210mm; min-height: 297mm; 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; 
    transition: box-shadow 0.3s ease, border 0.3s ease;
    padding: 20mm 25mm; 
    font-family: "Times New Roman", Times, serif; font-size: 14pt; line-height: 1.5; color: #000000;
}

/* Định dạng các thẻ HTML sinh ra từ AI */
.mk-native-editor p { margin-top: 0; margin-bottom: 12px; text-align: justify; }
.mk-native-editor h2, .mk-native-editor h3, .mk-native-editor h4 { text-align: center; font-weight: bold; margin-top: 20px; margin-bottom: 15px; }
.mk-native-editor ul, .mk-native-editor ol { padding-left: 20px; margin-bottom: 12px; }
.mk-native-editor li { margin-bottom: 6px; text-align: justify; line-height: 1.5; }
.mk-native-editor strong, .mk-native-editor b { font-weight: bold; }
.mk-native-editor em, .mk-native-editor i { font-style: italic; }

/* ==========================================================================
   4.3. CSS TỐI ƯU HÓA XUẤT PDF VÀ IN ẤN
   ========================================================================== */
.mk-native-editor h2, .mk-native-editor h3, .mk-native-editor h4 { page-break-after: avoid; }
.mk-native-editor p { page-break-inside: avoid; }
.mk-native-editor table { page-break-inside: auto; border-collapse: collapse; width: 100%; margin-bottom: 15px; }
.mk-native-editor tr { page-break-inside: avoid; page-break-after: auto; }
.mk-native-editor td, .mk-native-editor th { border: 1px solid #000; padding: 5px; }

/* ==========================================================================
   5. KHU VỰC CHAT AI (Khung ra lệnh)
   ========================================================================== */
.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: #0369a1; box-shadow: 0 0 0 4px rgba(3, 105, 161, 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 (BUTTONS)
   ========================================================================== */
.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: #0369a1; border: 1px solid #0369a1; }
.mk-btn-outline:hover { background-color: #f0f9ff; }
.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: #0369a1; color: white; width: 44px; height: 44px; padding: 0; border-radius: 12px;}
.mk-btn-submit:hover { background-color: #075985; }
.mk-btn-submit:disabled { background-color: #cbd5e1; cursor: not-allowed; }

/* Loader Xoay */
.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; }
}