/* ═══════════════════════════════════════════════════
   KhongGianAI – Project Management (Kanban Board)
   ═══════════════════════════════════════════════════ */

/* ── Layout ─────────────────────────────────────── */
.kpm-app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 16px;
    min-height: calc(100vh - 200px)
}

/* Header bar */
.kpm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap
}

.kpm-header-left {
    display: flex;
    align-items: center;
    gap: 12px
}

.kpm-header-left h1 {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0
}

.kpm-project-key {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px
}

.kpm-header-right {
    display: flex;
    align-items: center;
    gap: 8px
}

/* View Tabs */
.kpm-view-tabs {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.06)
}

.kpm-view-tab {
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #9ca3af;
    border: none;
    background: none;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px
}

.kpm-view-tab:hover {
    color: #e5e7eb
}

.kpm-view-tab.active {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3)
}

.kpm-view-tab i {
    width: 14px;
    height: 14px
}

/* Action Buttons */
.kpm-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px
}

.kpm-btn-primary {
    margin: auto;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25)
}

.kpm-btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4)
}

.kpm-btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.08)
}

.kpm-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e7eb
}

.kpm-btn i {
    width: 14px;
    height: 14px
}

/* Filter bar */
.kpm-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center
}

.kpm-filter-chip {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: #9ca3af;
    cursor: pointer;
    transition: all .2s
}

.kpm-filter-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb
}

.kpm-filter-chip.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.3)
}

.kpm-search {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 7px 12px;
    color: #e5e7eb;
    font-size: 13px;
    outline: none;
    width: 220px;
    transition: border-color .2s
}

.kpm-search:focus {
    border-color: rgba(99, 102, 241, 0.4)
}

.kpm-search::placeholder {
    color: #6b7280
}

/* ── Kanban Board ───────────────────────────────── */
.kpm-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 20px;
    align-items: flex-start
}

.kpm-board::-webkit-scrollbar {
    height: 6px
}

.kpm-board::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px
}

.kpm-board::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px
}

/* Column */
.kpm-column {
    min-width: 300px;
    max-width: 340px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 260px)
}

.kpm-column-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06)
}

.kpm-column-title {
    display: flex;
    align-items: center;
    gap: 8px
}

.kpm-column-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0
}

.kpm-column-name {
    font-size: 13px;
    font-weight: 700;
    color: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: .5px
}

.kpm-column-count {
    background: rgba(255, 255, 255, 0.06);
    color: #9ca3af;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700
}

.kpm-column-add {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    color: #6b7280;
    border: none;
    cursor: pointer;
    transition: all .15s
}

.kpm-column-add:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8
}

.kpm-column-add i {
    width: 14px;
    height: 14px
}

/* Column body (droppable area) */
.kpm-column-body {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 100px
}

.kpm-column-body::-webkit-scrollbar {
    width: 4px
}

.kpm-column-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px
}

/* Drag states */
.kpm-column-body.drag-over {
    background: rgba(99, 102, 241, 0.04);
    border-radius: 0 0 11px 11px
}

/* ── Task Card ──────────────────────────────────── */
.kpm-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all .2s;
    position: relative
}

.kpm-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15)
}

.kpm-card:active {
    cursor: grabbing;
    opacity: 0.9
}

.kpm-card.dragging {
    opacity: 0.4;
    border: 2px dashed rgba(99, 102, 241, 0.4)
}

.kpm-card-key {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between
}

.kpm-card-key span {
    display: flex;
    align-items: center;
    gap: 4px
}

.kpm-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 10px;
    line-height: 1.4
}

.kpm-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px
}

.kpm-card-labels {
    display: flex;
    gap: 4px;
    flex-wrap: wrap
}

.kpm-card-label {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px
}

.kpm-card-label.bug {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171
}

.kpm-card-label.feature {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80
}

.kpm-card-label.improvement {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa
}

.kpm-card-label.design {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc
}

.kpm-card-right {
    display: flex;
    align-items: center;
    gap: 8px
}

.kpm-card-priority {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 10px
}

.kpm-card-priority.high {
    color: #f87171
}

.kpm-card-priority.medium {
    color: #fbbf24
}

.kpm-card-priority.low {
    color: #60a5fa
}

.kpm-card-priority.critical {
    color: #ef4444;
    animation: kpm-pulse 1.5s infinite
}

@keyframes kpm-pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .5
    }
}

.kpm-card-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0
}

.kpm-card-subtask {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #6b7280
}

.kpm-card-subtask i {
    width: 12px;
    height: 12px
}

.kpm-card-due {
    font-size: 11px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px
}

.kpm-card-due.overdue {
    color: #f87171
}

.kpm-card-due i {
    width: 12px;
    height: 12px
}

/* ── Summary View ───────────────────────────────── */
.kpm-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px
}

.kpm-summary-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px
}

.kpm-summary-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: #e5e7eb;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px
}

.kpm-summary-card h3 i {
    width: 16px;
    height: 16px;
    color: #818cf8
}

.kpm-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

.kpm-stat-item {
    text-align: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px
}

.kpm-stat-value {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent
}

.kpm-stat-label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px
}

.kpm-progress-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    margin-top: 8px
}

.kpm-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    transition: width .5s ease
}

/* Member list */
.kpm-member-list {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.kpm-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02)
}

.kpm-member-row .kpm-card-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px
}

.kpm-member-info {
    flex: 1
}

.kpm-member-name {
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb
}

.kpm-member-role {
    font-size: 11px;
    color: #6b7280;
    text-transform: capitalize
}

.kpm-member-tasks {
    font-size: 12px;
    color: #818cf8;
    font-weight: 600
}

/* ── Activity ───────────────────────────────────── */
.kpm-activity-list {
    display: flex;
    flex-direction: column;
    gap: 0
}

.kpm-activity-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04)
}

.kpm-activity-item:last-child {
    border-bottom: none
}

.kpm-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #818cf8;
    margin-top: 5px;
    flex-shrink: 0
}

.kpm-activity-text {
    font-size: 13px;
    color: #9ca3af;
    line-height: 1.4
}

.kpm-activity-text strong {
    color: #e5e7eb
}

.kpm-activity-time {
    font-size: 11px;
    color: #4b5563;
    margin-top: 2px
}

/* ── Create Task Modal ──────────────────────────── */
.kpm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center
}

.kpm-modal-overlay.show {
    display: flex
}

.kpm-modal {
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: kpm-slideUp .25s ease
}

@keyframes kpm-slideUp {
    from {
        transform: translateY(20px);
        opacity: 0
    }

    to {
        transform: translateY(0);
        opacity: 1
    }
}

.kpm-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between
}

.kpm-modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #e5e7eb;
    margin: 0
}

.kpm-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    color: #6b7280;
    border: none;
    cursor: pointer;
    transition: all .15s
}

.kpm-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171
}

.kpm-modal-body {
    padding: 24px
}

.kpm-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: flex-end;
    gap: 8px
}

/* Form */
.kpm-form-group {
    margin-bottom: 16px
}

.kpm-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px
}

.kpm-input,
.kpm-textarea,
.kpm-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
    color: #e5e7eb;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box
}

.kpm-input:focus,
.kpm-textarea:focus,
.kpm-select:focus {
    border-color: rgba(99, 102, 241, 0.4)
}

.kpm-textarea {
    min-height: 100px;
    resize: vertical
}

.kpm-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center
}

.kpm-select option {
    background: #1a1a2e;
    color: #e5e7eb
}

.kpm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

/* ── Task Detail Panel ──────────────────────────── */
.kpm-detail-panel {
    position: fixed;
    top: 0;
    right: -600px;
    width: 560px;
    max-width: 95vw;
    height: 100vh;
    background: #1a1a2e;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 9998;
    transition: right .3s ease;
    overflow-y: auto;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3)
}

.kpm-detail-panel.open {
    right: 0
}

.kpm-detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: #1a1a2e;
    z-index: 1
}

.kpm-detail-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #e5e7eb
}

.kpm-detail-body {
    padding: 24px
}

.kpm-detail-section {
    margin-bottom: 24px
}

.kpm-detail-section h3 {
    font-size: 13px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px
}

.kpm-detail-section h3 i {
    width: 14px;
    height: 14px
}

/* Transition indicator */
.kpm-transition-msg {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    display: none;
    align-items: center;
    gap: 8px;
    animation: kpm-slideUp .3s ease
}

.kpm-transition-msg.success {
    display: flex;
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2)
}

.kpm-transition-msg.error {
    display: flex;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2)
}

/* ── Empty state ────────────────────────────────── */
.kpm-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280
}

.kpm-empty i {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: .3
}

.kpm-empty h3 {
    font-size: 16px;
    color: #9ca3af;
    margin: 0 0 8px
}

.kpm-empty p {
    font-size: 13px
}

/* ── Loading ────────────────────────────────────── */
.kpm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
    font-size: 13px;
    gap: 8px
}

.kpm-loading i {
    animation: spin 1s linear infinite
}

@keyframes spin {
    from {
        transform: rotate(0)
    }

    to {
        transform: rotate(360deg)
    }
}

/* ── Toast ──────────────────────────────────────── */
.kpm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    z-index: 99999;
    animation: kpm-slideUp .3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3)
}

.kpm-toast.success {
    background: rgba(34, 197, 94, 0.9);
    color: #fff
}

.kpm-toast.error {
    background: rgba(239, 68, 68, 0.9);
    color: #fff
}

.kpm-toast.info {
    background: rgba(99, 102, 241, 0.9);
    color: #fff
}

/* ── Responsive ─────────────────────────────────── */
@media(max-width:768px) {
    .kpm-header {
        flex-direction: column;
        align-items: flex-start
    }

    .kpm-board {
        flex-direction: column
    }

    .kpm-column {
        min-width: 100%;
        max-width: 100%
    }

    .kpm-form-row {
        grid-template-columns: 1fr
    }

    .kpm-detail-panel {
        width: 100%
    }

    .kpm-summary {
        grid-template-columns: 1fr
    }

    .kpm-filters {
        flex-direction: column;
        align-items: flex-start
    }
}

/* ── Light Mode ─────────────────────────────────── */
body.kgai-light .kpm-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08)
}

body.kgai-light .kpm-card:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(99, 102, 241, 0.2)
}

body.kgai-light .kpm-column {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08)
}

body.kgai-light .kpm-column-name {
    color: #1f2937
}

body.kgai-light .kpm-card-title {
    color: #1f2937
}

body.kgai-light .kpm-card-key {
    color: #6b7280
}

body.kgai-light .kpm-modal {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08)
}

body.kgai-light .kpm-modal-header {
    border-color: rgba(0, 0, 0, 0.08)
}

body.kgai-light .kpm-modal-header h2 {
    color: #1f2937
}

body.kgai-light .kpm-input,
body.kgai-light .kpm-textarea,
body.kgai-light .kpm-select {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1f2937
}

body.kgai-light .kpm-detail-panel {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08)
}

body.kgai-light .kpm-detail-header {
    background: #fff
}

body.kgai-light .kpm-detail-header h2 {
    color: #1f2937
}

body.kgai-light .kpm-summary-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06)
}

body.kgai-light .kpm-summary-card h3 {
    color: #1f2937
}

body.kgai-light .kpm-view-tabs {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06)
}

body.kgai-light .kpm-view-tab {
    color: #6b7280
}

body.kgai-light .kpm-view-tab:hover {
    color: #374151
}

body.kgai-light .kpm-search {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1f2937
}

body.kgai-light .kpm-btn-ghost {
    background: rgba(0, 0, 0, 0.03);
    color: #6b7280;
    border-color: rgba(0, 0, 0, 0.08)
}