/* --- ROOT VARIABLES --- */
:root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --primary: #4f46e5;       /* Indigo Modern */
    --primary-hover: #4338ca;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 12px;
}

/* --- RESET & GLOBAL --- */
* { box-sizing: border-box; outline: none; margin: 0; padding: 0; }
body { 
    font-family: 'Outfit', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    height: 100vh; 
    overflow: hidden; 
}

.engine-room { position: absolute; opacity: 0; pointer-events: none; }
.app-container { display: flex; flex-direction: column; height: 100%; }

/* --- HEADER --- */
.glass-header {
    height: 70px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 20px;
    box-shadow: var(--shadow-sm); z-index: 10; flex-shrink: 0;
}

/* Folder Group */
.folder-group { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.folder-wrapper { position: relative; }
.modern-select { 
    appearance: none; padding: 10px 16px 10px 40px; 
    border: 1px solid var(--border); border-radius: var(--radius); 
    background: #f9fafb; font-weight: 600; font-size: 14px; 
    cursor: pointer; min-width: 180px; transition: 0.2s; 
}
.modern-select:hover { border-color: var(--primary); background: white; }
.folder-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 16px; pointer-events: none; }

.icon-btn { 
    width: 38px; height: 38px; 
    border: 1px solid var(--border); border-radius: 10px; 
    background: white; color: var(--text-muted); cursor: pointer; 
    display: flex; align-items: center; justify-content: center; 
    transition: 0.2s; font-size: 16px; 
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); background: #eef2ff; }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }

/* Search Box */
.search-wrapper { flex: 1; }
.search-input-box { position: relative; width: 100%; }
.search-input-box input { 
    width: 100%; padding: 10px 16px 10px 44px; 
    border: 1px solid var(--border); border-radius: var(--radius); 
    background: #f9fafb; font-size: 14px; transition: 0.2s; 
}
.search-input-box input:focus { background: white; border-color: var(--primary); box-shadow: 0 0 0 3px #e0e7ff; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Navigation Tabs */
.right-control-group { 
    display: flex; align-items: center; gap: 16px; 
    background: white; padding: 5px; border-radius: 14px; 
    border: 1px solid var(--border); 
}
.nav-tabs { display: flex; gap: 4px; }
.tab-btn { 
    border: none; background: transparent; padding: 8px 16px; 
    border-radius: 10px; font-weight: 600; font-size: 13px; 
    color: var(--text-muted); cursor: pointer; transition: 0.2s; 
}
.tab-btn:hover { color: var(--text); background: #f3f4f6; }
.tab-btn.active { background: var(--primary); color: white; }
.divider-vertical { width: 1px; height: 24px; background: var(--border); align-self: center; }

/* Toggle */
.smart-toggle-wrapper { padding-right: 10px; }
.smart-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.smart-toggle input { display: none; }
.toggle-track { 
    width: 44px; height: 24px; background: #e5e7eb; border-radius: 20px; 
    position: relative; transition: 0.3s; 
}
.toggle-thumb { 
    width: 20px; height: 20px; background: white; border-radius: 50%; 
    position: absolute; top: 2px; left: 2px; transition: 0.3s; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}
input:checked + .toggle-track { background: var(--primary); }
input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* --- MAIN STAGE --- */
.main-stage { flex: 1; position: relative; padding: 20px 24px; overflow: hidden; }
.view-panel { 
    position: absolute; inset: 20px 24px; display: none; 
    flex-direction: column; animation: fadeIn 0.2s ease; 
}
.view-panel.active { display: flex; }

/* Control Bar */
.control-bar { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 20px; background: white; padding: 12px 20px; 
    border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); 
}
.custom-chk { display: flex; align-items: center; cursor: pointer; }
.custom-chk input { display: none; }
.checkmark { 
    width: 20px; height: 20px; border: 2px solid var(--border); 
    border-radius: 6px; margin-right: 10px; display: flex; 
    align-items: center; justify-content: center; 
}
.custom-chk input:checked ~ .checkmark { background: var(--primary); border-color: var(--primary); }
.checkmark:after { content: "✔"; color: white; font-size: 12px; display: none; }
.custom-chk input:checked ~ .checkmark:after { display: block; }

.bar-right { display: flex; gap: 10px; }
.action-pill { 
    border: 1px solid var(--border); background: white; 
    border-radius: 99px; padding: 8px 16px; font-weight: 600; 
    font-size: 13px; cursor: pointer; transition: 0.2s; 
    display: flex; align-items: center; gap: 8px; 
}
.action-pill:hover { border-color: var(--primary); color: var(--primary); }
.action-pill.primary { background: var(--primary); color: white; border-color: var(--primary); }
.action-pill.danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }

/* Grid Files (Fixed Padding for Shadow) */
.grid-container { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
    gap: 20px; 
    overflow-y: auto; 
    padding: 10px 10px 20px 10px; /* Fix lẹm viền */
}
.file-card { 
    background: white; border: 1px solid var(--border); 
    border-radius: 16px; padding: 16px; display: flex; 
    flex-direction: column; gap: 12px; cursor: pointer; 
    transition: 0.2s; margin: 2px;
}
.file-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.file-card.selected { background: #eef2ff; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.card-icon { 
    width: 40px; height: 40px; background: #e0e7ff; color: var(--primary); 
    border-radius: 10px; display: flex; align-items: center; 
    justify-content: center; font-size: 20px; 
}
.file-name { 
    font-weight: 700; font-size: 15px; display: -webkit-box; 
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; 
}
.file-meta { font-size: 12px; color: var(--text-muted); }

/* --- TABLE SYSTEM --- */
.table-container { 
    background: white; border-radius: 16px; border: 1px solid var(--border); 
    flex: 1; display: flex; flex-direction: column; overflow: hidden; 
    box-shadow: var(--shadow-sm); 
}
.panel-header-flex { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

/* Shared Row */
.tbl-head, .table-row, .checklist-item { 
    display: flex; align-items: center; padding: 0 24px; 
}
.tbl-head { 
    height: 50px; background: #f9fafb; border-bottom: 1px solid var(--border); 
    font-weight: 700; font-size: 13px; color: var(--text-muted); 
    text-transform: uppercase; flex-shrink: 0; 
}
.tbl-body { flex: 1; overflow-y: auto; }
.table-row, .checklist-item { 
    min-height: 54px; border-bottom: 1px solid #f3f4f6; 
    font-size: 14px; color: var(--text); transition: 0.1s; 
}
.table-row:hover, .checklist-item:hover { background: #f9fafb; }

/* Columns */
.col-time { width: 150px; flex-shrink: 0; font-family: monospace; color: var(--text-muted); }
.col-type { width: 130px; flex-shrink: 0; }
.col-msg  { flex: 1; padding-left: 20px; border-left: 1px solid #f3f4f6; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.col-status { width: 160px; flex-shrink: 0; }
.col-name   { flex: 1; font-weight: 500; margin-right: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-idx    { width: 80px; text-align: right; font-weight: 700; color: var(--text-muted); margin-left: auto; }

/* Spinner & Status */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 14px; height: 14px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
.checklist-item.done { background: #f0fdf4; opacity: 0.85; }
.checklist-item.done .col-name, .checklist-item.done .col-idx { text-decoration: line-through; color: #15803d; }

.status-badge { 
    display: inline-flex; align-items: center; gap: 8px; 
    padding: 6px 12px; border-radius: 20px; 
    font-size: 12px; font-weight: 700; text-transform: uppercase; 
}
.status-badge.pending { background: white; border: 1px solid #e2e8f0; color: var(--text-muted); }
.status-badge.done { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }

/* Common Elements */
.btn-rounded-danger { 
    background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; 
    padding: 8px 20px; border-radius: 99px; font-weight: 600; 
    cursor: pointer; transition: 0.2s; font-size: 13px; 
    display: flex; align-items: center; gap: 6px; 
}
.btn-rounded-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

.filter-group { display: flex; gap: 8px; background: #f3f4f6; padding: 4px; border-radius: 99px; }
.filter-btn { 
    border: none; background: transparent; padding: 6px 16px; 
    border-radius: 99px; font-weight: 600; font-size: 13px; 
    color: var(--text-muted); cursor: pointer; transition: 0.2s; 
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.badge { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge.success { background: #dcfce7; color: #15803d; } 
.badge.error { background: #fee2e2; color: #b91c1c; }   
.badge.info { background: #e0e7ff; color: #4338ca; }    

.progress-container-full { 
    display: flex; align-items: center; gap: 15px; 
    background: white; padding: 8px 20px; border-radius: 12px; 
    border: 1px solid var(--border); flex: 1; margin-right: 15px; 
}
.prog-title { font-weight: 600; font-size: 14px; }
.prog-val { font-weight: 700; color: var(--primary); min-width: 40px; }
.prog-bar-wrapper { flex: 1; }
.prog-track { width: 100%; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--success); width: 0%; transition: 0.5s; }

/* MODAL & TOAST */
.modal-backdrop { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); 
    backdrop-filter: blur(2px); z-index: 100; display: none; 
    align-items: center; justify-content: center; 
}
.modal-backdrop.show { display: flex; }
.modal-content { 
    width: 90%; max-width: 900px; height: 90vh; 
    background: #f3f4f6; border-radius: 16px; display: flex; 
    flex-direction: column; overflow: hidden; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); 
}
.modal-top { 
    height: 60px; background: white; display: flex; 
    align-items: center; justify-content: space-between; 
    padding: 0 24px; border-bottom: 1px solid var(--border); 
}

/* Modal Counter */
.modal-nav { display: flex; align-items: center; gap: 10px; }
.modal-counter {
    font-size: 13px; font-weight: 700; color: var(--primary);
    background: #eef2ff; padding: 6px 12px; border-radius: 99px;
    border: 1px solid #e0e7ff; min-width: 100px; text-align: center;
}

.doc-paper { 
    background: white; max-width: 800px; margin: 30px auto; 
    padding: 60px; min-height: 100%; box-shadow: var(--shadow-md); 
}
.modal-scroll { flex: 1; overflow-y: auto; }

.toast { 
    position: fixed; top: 20px; right: 20px; background: #1f2937; 
    color: white; padding: 12px 24px; border-radius: 10px; 
    font-weight: 600; transform: translateY(-100%); opacity: 0; 
    transition: 0.3s; z-index: 200; 
}
.toast.show { transform: translateY(0); opacity: 1; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
