:root {
  --bg: #0f172a;
  --panel: #111827;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --brand: #22c55e;
  --accent: #00aeef;
  --danger: #ef4444;
  --warn: #f59e0b;
  --col-bg: #0b1220;
  --chip: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial;
  min-height: 100vh;
}

body.light-mode {
    --bg: #f9fafb;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --col-bg: #f3f4f6;
    --chip: #e5e7eb;
    background: #f9fafb;
    color: var(--text);
}
body.light-mode input,
body.light-mode textarea,
body.light-mode select {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}
body.light-mode .chip {
    color: #374151;
    border-color: #d1d5db;
}
body.light-mode button.ghost {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}
body.light-mode header {
    background: rgba(255,255,255,.8);
    border-bottom-color: #e5e7eb;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #1f2937;
}

.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 20px;
  margin: 6px 0;
}

.grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #1f2937;
  background: #0b1220;
  color: var(--text);
  outline: none;
}

label {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  color: #0b1220;
  background: var(--accent);
  font-weight: 600;
  transition: background-color 0.2s;
}

button:hover {
    filter: brightness(1.1);
}

button.ghost {
  background: #0b1220;
  color: var(--text);
  border: 1px solid #1f2937;
}

button.warn {
  background: var(--warn);
  color: #0b1220;
}

button.danger {
  background: var(--danger);
  color: white;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 12px;
}

.col {
  background: var(--col-bg);
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 240px;
}

.col h3 {
  margin: 0 0 8px 6px;
  font-size: 14px;
  color: #cbd5e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drop {
  flex: 1;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: #0e1627;
  border: 1px solid #1f2937;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  cursor: grab;
}

.card.dragging {
  opacity: 0.5;
  background: var(--accent);
}

.title {
  font-weight: 700;
}

.meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.chip {
  font-size: 11px;
  background: var(--chip);
  padding: 3px 8px;
  border-radius: 999px;
  color: #cbd5e1;
  border: 1px solid #293241;
}

.pri-High { background: #3b1d1d; color: #fecaca; border-color: #7f1d1d; }
.pri-Critical { background: #4c1d1d; color: #fecaca; border-color: #b91c1c; }
.pri-Low { background: #14251d; color: #bbf7d0; border-color: #14532d; }

.due { color: #fca5a5; }
.overdue { border-color: #b91c1c; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  flex: 1;
}

.footer {
  margin-top: 16px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}

#miniTimer {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #0e1627;
  border: 1px solid #1f2937;
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 99;
}

#miniTimer.drag {
  opacity: 0.9;
  cursor: move;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.hidden {
  display: none;
}

dialog {
    width: 100%;
    max-width: 600px;
    border: none;
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: transparent;
    margin: auto;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    background-color: var(--panel);
    min-width: 220px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4);
    z-index: 100;
    border-radius: 12px;
    border: 1px solid #1f2937;
    padding: 0.5rem 0;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    color: var(--text);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
}

.dropdown-menu a:hover {
    background-color: var(--col-bg);
}

.dropdown-menu .danger-text {
    color: var(--danger);
}

.dropdown-menu .danger-text:hover {
    background-color: rgba(239, 68, 68, 0.1); 
}

.dropdown-menu a.disabled {
    color: var(--muted);
    opacity: 0.5;
    cursor: not-allowed;
}

.dropdown-menu a.disabled span {
    pointer-events: none; 
}

.dropdown-menu a.disabled:hover {
    background-color: transparent;
}

.chip-link {
    text-decoration: none;
}

#subtasks-container {
    border-top: 1px solid #1f2937;
    padding-top: 1rem;
}

.subtasks-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    max-height: 200px;
    overflow-y: auto;
}

.subtasks-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
}

.subtasks-list li:hover {
    background-color: #1f2937;
}

.subtasks-list input[type="checkbox"] {
    width: auto;
    flex-shrink: 0;
}

.subtasks-list .subtask-title {
    flex-grow: 1;
    border: none;
    background: transparent;
    color: var(--text);
    padding: 4px;
}

.subtasks-list .subtask-title.completed {
    text-decoration: line-through;
    color: var(--muted);
}

.subtasks-list .delete-subtask-btn {
    background: transparent;
    color: var(--muted);
    padding: 4px 8px;
    visibility: hidden;
}

.subtasks-list li:hover .delete-subtask-btn {
    visibility: visible;
}

.add-subtask-wrapper {
    display: flex;
    gap: 0.5rem;
}

.sidebar-tagify {
    --tags-border-color: #1f2937;
    --tags-bg: #0b1220;
    --tag-bg: var(--accent);
    --tag-text-color: #fff;
    min-width: 150px; 
}
.sidebar-tagify + input[id="tag-filter-input"] {
    display: none !important;
}

.suggestions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.suggestion-item {
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid #1f2937;
    cursor: pointer;
    transition: background-color 0.2s;
}

.suggestion-item:hover {
    background-color: var(--col-bg);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-title {
    font-weight: 500;
}

.suggestion-meta {
    font-size: 0.8em;
    color: var(--muted);
    margin-top: 4px;
}
.suggestion-meta .pri-chip {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    margin-left: 8px;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.load-more-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

body.auth-page-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem; 
}

.auth-form { 
    width: 100%; 
    max-width: 400px; 
}

.auth-form .form-group { 
    margin-bottom: 1rem; 
}

.auth-form button[type="submit"] { 
    width: 100%;
}

.error { 
    color: var(--danger); 
    text-align: center; 
    margin-bottom: 1rem; 
}

.switch-form { 
    text-align: center; 
    margin-top: 1rem; 
}

.note-card {
    background: var(--panel);
    border: 1px solid #1f2937;
    border-radius: 12px;
    padding: 1rem;
    min-height: 150px;
    display: flex; /* Sử dụng flexbox */
    flex-direction: column; /* Xếp các phần tử theo chiều dọc */
    justify-content: space-between; /* Đẩy ngày tháng xuống dưới cùng */
}

.note-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px; /* << Giới hạn chiều cao nội dung */
    overflow-y: auto;  /* << Thêm thanh cuộn khi nội dung dài */
    flex-grow: 1; /* Cho phép nội dung co giãn */
}

.note-date {
    font-size: 0.8em;
    color: var(--muted);
    margin-top: 1rem;
    text-align: right;
    flex-shrink: 0; /* Ngăn ngày tháng bị co lại */
}

@media (max-width: 768px) {

    .grid {
        grid-template-columns: 1fr;
    }

    .wrap {
        padding: 8px;
    }

    header .toolbar {
        flex-direction: column; 
        align-items: flex-start;
        gap: 12px;
    }
    
    .board-selector {
        width: 100%; 
        margin-left: 0 !important;
    }
    
    .board-selector select {
        flex-grow: 1; 
    }

    .actions, .user-info {
        width: 100%;
        margin-left: 0 !important;
        justify-content: space-between; 
    }
    
    #current-task-focus {
        display: none !important; 
    }

    .kanban {
        grid-template-columns: repeat(5, 80vw); 
        overflow-x: auto;
        scroll-snap-type: x mandatory; 
        padding-bottom: 12px; 
    }

    .kanban .col {
        scroll-snap-align: start; 
    }

    .panel {
        padding: 12px;
    }

    .split {
        grid-template-columns: 1fr;
    }

    dialog {
        width: calc(100% - 16px);
        max-width: none;
    }
    
    .fc .fc-header-toolbar {
        font-size: 0.85em;
        flex-direction: column;
        gap: 1rem;
    }
    
    .fc .fc-header-toolbar .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    /* --- AUTH PAGES ON MOBILE --- */
    .auth-form {
        max-width: none;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }
    
    .auth-form h1 {
        font-size: 1.8em; 
    }
}/* =============================================== */
/*              EASYMDE DARK THEME                 */
/* =============================================== */

/* Ghi đè style chung của trình soạn thảo */
.EasyMDEContainer,
.editor-toolbar {
    background-color: #ffffff !important;
    border-color: var(--chip) !important;
    color: var(--text) !important;
}

/* Nền của vùng soạn thảo */
.CodeMirror {
    background-color: var(--panel) !important;
    border-color: var(--chip) !important;
    color: var(--text) !important;
}

/* Con trỏ soạn thảo */
.CodeMirror-cursor {
    border-left: 1px solid var(--text) !important;
}

.editor-toolbar a {
    color: #a3a3a3 !important; /* Sử dụng một màu xám sáng hơn, hoặc var(--text) nếu muốn trắng sáng */
    opacity: 0.8; /* Làm cho icon hơi mờ đi một chút */
    transition: opacity 0.2s, color 0.2s; /* Thêm hiệu ứng chuyển động mượt */
}

/* Hiệu ứng khi di chuột hoặc khi nút được kích hoạt - làm cho nó sáng rõ nhất */
.editor-toolbar a:hover,
.editor-toolbar a.active {
    background-color: var(--chip) !important;
    color: #ffffff !important; /* Màu trắng sáng nhất */
    opacity: 1; /* Hiển thị đầy đủ */
}

/* Đường kẻ phân cách trên thanh công cụ */
.editor-toolbar i.separator {
    border-color: var(--chip) !important;
}

/* Thanh trạng thái ở dưới (nếu có) */
.editor-statusbar {
    color: var(--muted) !important;
}

/* Chế độ xem trước (preview) */
.editor-preview,
.editor-preview-side {
    background-color: var(--col-bg) !important;
}