@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Baloo 2', 'Comic Sans MS', Arial, sans-serif;
    background: linear-gradient(135deg, #654ea3, #eaafc8);
    min-height: 100vh;
    padding: 10px 20px 60px;
}

/* === VISITOR COUNTER === */
.visitor-counter {
    position: fixed;
    top: 10px;
    right: 14px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    border-radius: 18px;
    padding: 4px 14px;
    font-size: 12px;
    color: #555;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    z-index: 9999;
}
.visitor-counter strong { color: #7c3aed; }

/* === PAGE LAYOUT (container + history sidebar) === */
.page-layout {
    display: flex;
    gap: 16px;
    max-width: 1440px;
    margin: 0 auto;
    align-items: flex-start;
}

.container {
    flex: 1;
    min-width: 0;
}

/* === HISTORY SIDEBAR === */
.history-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 30px);
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 2px solid #eee;
}

.history-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.history-clear-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s;
    padding: 2px 4px;
}
.history-clear-btn:hover { opacity: 1; }

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}

.history-empty {
    color: #aaa;
    font-size: 13px;
    text-align: center;
    font-style: italic;
    padding: 20px 0;
}

/* History card */
.history-card {
    background: white;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-left: 4px solid #7c3aed;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.history-card:hover {
    transform: translateX(3px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.history-card.completed {
    border-left-color: #2e7d32;
}

.history-card-name {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-card-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: #888;
    flex-wrap: wrap;
}

.history-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.history-card-status {
    display: inline-block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 8px;
}
.history-card-status.done {
    background: #E8F5E9;
    color: #2e7d32;
}
.history-card-status.in-progress {
    background: #FFF8E1;
    color: #e65100;
}

/* === HISTORY MODAL === */
.history-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.history-modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: bounceIn 0.3s ease;
}

.history-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.history-modal-close:hover { color: #333; }

.history-modal-title {
    font-size: 22px;
    color: #7c3aed;
    margin-bottom: 4px;
    text-transform: none;
    max-width: none;
    padding-right: 30px;
}

.history-modal-desc {
    font-size: 13px;
    color: #777;
    margin-bottom: 16px;
}

.history-modal-columns {
    display: flex;
    gap: 10px;
}

.history-modal-col {
    flex: 1;
    background: #f9f9f9;
    border-radius: 10px;
    padding: 10px;
    min-height: 120px;
}

.history-modal-col h4 {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-align: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #eee;
}

.history-task-card {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    color: white;
    font-size: 12px;
    margin-bottom: 5px;
}

.history-task-card img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.4);
}

.history-task-card .htc-name {
    font-weight: 700;
    white-space: nowrap;
}

.history-task-card .htc-desc {
    flex: 1;
    opacity: 0.9;
}

@media screen and (max-width: 900px) {
    .page-layout { flex-direction: column; }
    .history-sidebar {
        width: 100%;
        position: static;
        max-height: none;
        margin-top: 16px;
    }
    .history-modal-columns { flex-direction: column; }
}

/* === HEADINGS === */
h1 {
    color: #fff;
    font-size: 34px;
    font-weight: 700;
    text-align: center;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.2);
    margin-bottom: 20px;
    line-height: 1.3;
}

h2 {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === ROUND NUMBER BADGE === */
.round-div {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

/* === BODY SECTION === */
.body-section {
    display: flex;
    gap: 16px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* === TEAM / JOB SETUP === */
#team-setup, #job-setup {
    flex: 1;
    min-width: 260px;
}

#infor-table {
    flex: 1;
    min-width: 200px;
}

#task-assignments-wrap {
    flex: 1;
    min-width: 280px;
}

/* === FORMS === */
#team-form, #job-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-row label {
    font-size: 14px;
    font-weight: 600;
    color: #444;
}

.input-row input[type="text"],
.input-row textarea {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
}

.input-row input[type="text"]:focus,
.input-row textarea:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.input-row textarea {
    min-height: 80px;
    resize: vertical;
}

.input-row input[type="file"] {
    font-size: 13px;
    padding: 6px;
}

.button-row {
    text-align: center;
    margin-top: 4px;
}

/* === SUBMIT BUTTON === */
.submit-button {
    background: linear-gradient(135deg, #8614f8, #760be0);
    border: none;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 10px 24px;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(118,11,224,0.3);
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(118,11,224,0.4);
}

.submit-button:active {
    transform: translateY(0);
}

/* === TEAM LIST === */
#team-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.team-member {
    border: 2px solid #7c3aed;
    border-radius: 10px;
    text-align: center;
    padding: 6px;
    width: 90px;
    background: white;
    transition: transform 0.15s;
}

.team-member:hover {
    transform: scale(1.05);
}

.team-member img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: grab;
}

.team-member p {
    font-weight: 700;
    font-size: 12px;
    color: #333;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === ROBOT IMAGE === */
#fun-image {
    flex-shrink: 0;
    width: 140px;
    display: flex;
    align-items: center;
}

#fun-image img {
    width: 100%;
    height: auto;
    border-radius: 10px;
}

/* === TASK ASSIGNMENTS (nhiều việc mỗi thành viên) === */
.member-tasks-section {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid #eee;
}

.member-tasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.member-tasks-header strong {
    font-size: 14px;
    color: #333;
}

.add-task-btn {
    background: #7c3aed;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.add-task-btn:hover {
    background: #6d28d9;
}

.member-task-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-input-row {
    display: flex;
    gap: 6px;
    align-items: flex-start;
}

.task-input-row textarea {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    min-height: 38px;
    resize: vertical;
    transition: border-color 0.2s;
}

.task-input-row textarea:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.remove-task-btn {
    background: #ef5350;
    color: white;
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 5px;
    transition: background 0.15s;
}

.remove-task-btn:hover {
    background: #d32f2f;
}

/* === KANBAN BOARD === */
#kanban-board {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

#kanban-table-name {
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.2);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.kanban-columns {
    display: flex;
    gap: 12px;
}

.kanban-column {
    flex: 1;
    min-height: 300px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s;
}

.kanban-column h3 {
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: #555;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}

.kanban-save-row {
    text-align: center;
    margin-top: 12px;
}

.save-project-btn {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 3px 10px rgba(124,58,237,0.3);
}

.save-project-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(124,58,237,0.4);
}

#todo-column h3 { color: #e65100; }
#in-progress-column h3 { color: #1565c0; }
#done-column h3 { color: #2e7d32; }

/* === KANBAN CARD (task) === */
.task {
    margin-bottom: 8px;
}

.image-container {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    border: none;
    padding: 8px;
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s;
}

.image-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.kaban-block-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.kaban-block-avatar img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
}

.kanban-block-name {
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
    min-width: 50px;
}

p.kanban-block-task-description {
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    flex: 1;
    line-height: 1.4;
}

/* === DRAG STATES === */
.dragging {
    opacity: 0.4;
    transform: rotate(2deg);
}

.dragging-over {
    border: 2px dashed #7c3aed;
    background: rgba(124,58,237,0.08);
}

/* === CHÚC MỪNG OVERLAY === */
.congrats-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.congrats-box {
    background: white;
    border-radius: 20px;
    padding: 36px 44px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: bounceIn 0.5s ease;
    max-width: 400px;
}

.congrats-emoji {
    font-size: 48px;
    margin-bottom: 10px;
}

.congrats-title {
    font-size: 28px;
    color: #7c3aed;
    margin-bottom: 8px;
    text-transform: none;
    max-width: none;
}

.congrats-text {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 18px;
}

.congrats-btn {
    background: linear-gradient(135deg, #8614f8, #760be0);
    color: white;
    border: none;
    padding: 12px 32px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s;
}

.congrats-btn:hover {
    transform: scale(1.05);
}

/* === CONFETTI === */
.confetti-piece {
    position: fixed;
    top: -10px;
    border-radius: 2px;
    z-index: 10001;
    animation: confettiFall linear forwards;
    pointer-events: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* === RESPONSIVE === */
@media screen and (max-width: 768px) {
    .body-section {
        flex-direction: column;
    }
    .kanban-columns {
        flex-direction: column;
    }
    #fun-image {
        display: none;
    }
    h1 {
        font-size: 24px;
    }
}
