/* =========================================================================
   OKR LIFE — style.css
   Thuần CSS3, không dùng framework. Hỗ trợ theme sáng/tối qua [data-theme].
   Responsive: sidebar chuyển thành menu trượt (drawer) trên mobile (<900px).
   ========================================================================= */

/* ---------- 1. BIẾN MÀU (CSS CUSTOM PROPERTIES) ---------- */
:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #eef2ff;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;

  --bg-body: #f4f5fb;
  --bg-surface: #ffffff;
  --bg-sidebar: #16172b;
  --bg-sidebar-hover: #262845;
  --text-main: #1f2333;
  --text-muted: #6b7280;
  --text-inverse: #f5f6fa;
  --border-color: #e5e7eb;
  --shadow-card: 0 1px 3px rgba(20, 20, 43, 0.06), 0 1px 2px rgba(20,20,43,0.04);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg-body: #0f1120;
  --bg-surface: #1a1c30;
  --bg-sidebar: #0b0c18;
  --bg-sidebar-hover: #1f2138;
  --text-main: #eceef5;
  --text-muted: #9ca0b5;
  --text-inverse: #0f1120;
  --border-color: #2a2c47;
  --color-primary-light: #23264a;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  transition: background .2s ease, color .2s ease;
}
a { color: var(--color-primary); text-decoration: none; }
h1, h2, h3 { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- 2. LAYOUT SHELL ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px; font-weight: 700; font-size: 18px;
}
.brand-icon { font-size: 22px; }
.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(245,246,250,0.75); font-size: 14.5px; font-weight: 500;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--color-primary); color: #fff; }
.nav-icon { font-size: 17px; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-logout { color: #fca5a5; }
.nav-logout:hover { background: rgba(220,38,38,0.15); color: #fecaca; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 30;
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 20px; font-weight: 700; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 14px; color: var(--text-muted); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase;
}

.content { flex: 1; padding: 22px 24px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }

.app-footer {
  text-align: center; padding: 16px; color: var(--text-muted); font-size: 12.5px;
  border-top: 1px solid var(--border-color);
}

.btn-icon {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-main); padding: 4px 8px; border-radius: 6px;
}
.btn-icon:hover { background: var(--color-primary-light); }

/* Toggle nút menu chỉ hiện trên mobile */
#btnToggleSidebar { display: none; }

/* ---------- 3. CARD / GRID ---------- */
.card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.card-header h2 { font-size: 16px; font-weight: 700; }
.card-body { padding: 18px 20px; }

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 18px; box-shadow: var(--shadow-card);
}
.stat-card.stat-warning { border-color: rgba(217,119,6,0.35); }
.stat-icon { font-size: 22px; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.link-more { font-size: 13px; font-weight: 600; white-space: nowrap; }
.empty-hint { color: var(--text-muted); font-size: 14px; padding: 10px 0; }
.text-muted { color: var(--text-muted); font-size: 13.5px; }
.divider { border: none; border-top: 1px solid var(--border-color); margin: 16px 0; }

/* ---------- 4. FORM ELEMENTS ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: var(--text-muted); }
.input, textarea.input, select.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-body); color: var(--text-main);
  font-size: 14px; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--color-primary); }
.input-inline { width: auto; display: inline-block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error {
  background: #fee2e2; color: #b91c1c; padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-top: 12px;
}
.form-success {
  background: #dcfce7; color: #15803d; padding: 9px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
}
.form-hint { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

/* ---------- 5. BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-primary-light); color: var(--color-primary); }
.btn-secondary:hover { filter: brightness(0.96); }
.btn-ghost { background: transparent; color: var(--text-main); border-color: var(--border-color); }
.btn-ghost:hover { background: var(--bg-body); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-danger { background: #fee2e2; color: var(--color-danger); }

/* ---------- 6. TOOLBAR / FILTERS ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.toolbar-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar-filters .input { width: auto; min-width: 150px; }

/* ---------- 7. OBJECTIVES / OKR ---------- */
.objectives-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.objective-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-card);
}
.objective-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.objective-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.objective-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--color-primary-light); color: var(--color-primary);
}
.badge-status-active { background: #dbeafe; color: #1d4ed8; }
.badge-status-completed { background: #dcfce7; color: #15803d; }
.badge-status-paused { background: #fef3c7; color: #b45309; }
.badge-status-cancelled { background: #fee2e2; color: #b91c1c; }

.progress-bar-track {
  height: 9px; border-radius: 999px; background: var(--bg-body); overflow: hidden; margin: 8px 0;
}
.progress-bar-fill { height: 100%; background: var(--color-primary); border-radius: 999px; transition: width .3s ease; }
.progress-label { font-size: 12.5px; color: var(--text-muted); display: flex; justify-content: space-between; }

.kr-list { margin-top: 12px; border-top: 1px dashed var(--border-color); padding-top: 10px; }
.kr-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 13.5px; }
.kr-item-title { flex: 1; }
.kr-item-value { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.kr-mini-input { width: 70px; padding: 4px 6px; font-size: 12.5px; }

.objective-card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- 8. KANBAN (Tasks) ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kanban-title { font-size: 14px; margin-bottom: 10px; color: var(--text-muted); }
.kanban-list { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.task-card {
  background: var(--bg-surface); border: 1px solid var(--border-color); border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm); padding: 12px; box-shadow: var(--shadow-card);
}
.task-card.priority-high { border-left-color: var(--color-danger); }
.task-card.priority-medium { border-left-color: var(--color-warning); }
.task-card.priority-low { border-left-color: var(--color-success); }
.task-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.task-meta { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; gap: 8px; }
.task-actions { display: flex; gap: 6px; margin-top: 8px; }
.overdue-card { border-color: rgba(220,38,38,0.35); }

/* ---------- 9. TABS (Reviews) ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.tab-btn {
  background: none; border: none; padding: 10px 16px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--color-primary); border-color: var(--color-primary); }

.review-history-item { padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.review-history-item:last-child { border-bottom: none; }
.review-history-date { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.review-history-field { font-size: 13px; margin-bottom: 3px; }
.review-history-field b { color: var(--text-muted); font-weight: 600; }

/* ---------- 10. LIFE AREAS ---------- */
.life-area-item { padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.life-area-item:last-child { border-bottom: none; }
.life-area-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.life-area-sliders { display: flex; gap: 14px; align-items: center; }
.life-area-sliders label { margin: 0; white-space: nowrap; }
.life-area-sliders input[type="range"] { flex: 1; }

/* ---------- 11. TABLE (Settings backups) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border-color); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; }

/* ---------- 12. THEME SWITCH (Settings) ---------- */
.theme-switch { display: flex; gap: 10px; }
.theme-option.active { background: var(--color-primary); color: #fff; }

/* ---------- 13. MODAL ---------- */
.modal {
  display: none; position: fixed; inset: 0; background: rgba(15,17,32,0.55);
  align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--bg-surface); border-radius: var(--radius-lg); width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { font-size: 16px; }
.modal-body { padding: 16px 20px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- 14. TOAST ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2333; color: #fff; padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--color-danger); }
.toast.toast-success { background: var(--color-success); }

/* ---------- 15. AUTH (LOGIN PAGE) ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed); margin: 0; padding: 20px;
}
.auth-card {
  background: #fff; border-radius: var(--radius-lg); padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.25);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-icon { font-size: 40px; display: block; margin-bottom: 6px; }
.auth-brand h1 { font-size: 22px; margin-bottom: 4px; }
.auth-brand p { font-size: 13px; color: #6b7280; margin: 0; }
.auth-form label { color: #374151; }
.auth-hint { text-align: center; font-size: 12.5px; color: #6b7280; margin-top: 18px; }

/* ---------- 16. RESPONSIVE ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: 10px 0 30px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  #btnToggleSidebar { display: inline-block; }
  .grid-2col { grid-template-columns: 1fr; }
  .objectives-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px 14px 30px; }
  .topbar { padding: 12px 14px; }
  .user-name { display: none; }
}
