/* 🔥 ส่วนที่เหลือของ CSS ให้คัดลอกจาก <style> เดิมทั้งหมดวางต่อท้ายได้เลย */


:root {
    --bg-desk: #fdf6e3;
    --sidebar-bg: #f8edeb;
    --primary-pastel: #ffddd2;
    --secondary-pastel: #e2ece9;
    --accent-pastel: #bee1e6;
    --copy-primary: #c7e9b0;
    --copy-secondary: #e1f2d5;
    --copy-border: #8eb486;
    --note-yellow: #fdf497;
    --danger-pastel: #ffaaa5;
    --deadline-color: #f8ad9d;
    --text-color: #5d5d5d;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', sans-serif;
}

body {
    background-color: var(--bg-desk);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}
/* Sidebar Style */
.sidebar {
    width: 80px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    border-right: 2px solid #f0e4e4;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
    z-index: 100;
}

.sidebar-item {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #888;
    position: relative;
}

.sidebar-item:hover {
    background-color: var(--primary-pastel);
    color: var(--text-color);
}

.sidebar-item.active {
    background-color: var(--primary-pastel);
    color: var(--text-color);
    box-shadow: var(--shadow);
}

.sidebar-item .tooltip {
    position: absolute;
    left: 70px;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    visibility: hidden;
    opacity: 0;
    transition: 0.3s;
    white-space: nowrap;
}

.sidebar-item:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Main Content Area */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 30px;
    overflow-y: auto;
    position: relative;
}

.view-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    margin-bottom: 35px;
}

.clock-container {
    font-family: 'Itim', cursive;
    font-size: 2rem;
    margin-bottom: 5px;
}

.date-display {
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Grid Layout for Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
    position: relative;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    margin-bottom: 0;
}

/* Calendar Styles */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 20px;
    position: relative;
}

.calendar-day-header {
    text-align: center;
    font-weight: bold;
    padding: 10px;
}

.calendar-day {
    min-height: 100px;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.2s;
    position: relative;
    user-select: none;
    overflow: hidden;
}

.calendar-day:hover {
    background: var(--secondary-pastel);
}

.calendar-day.current {
    border-color: var(--primary-pastel);
    background: #fff9f8;
}

.calendar-day.selected {
    background: var(--accent-pastel);
    border-color: #add8e6;
}

.calendar-day.copy-source {
    border: 2px dashed var(--copy-border) !important;
    background: var(--copy-secondary) !important;
    box-shadow: inset 0 0 8px rgba(142, 180, 134, 0.2);
}

.calendar-day.copy-target {
    border: 2px solid var(--copy-primary) !important;
    background: var(--copy-secondary) !important;
}

.calendar-day.batch-selected {
    background: var(--danger-pastel) !important;
    color: white !important;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.day-number {
    font-weight: bold;
    font-size: 0.85rem;
}

.day-indicators {
    display: flex;
    gap: 2px;
    align-items: center;
}

.day-indicator-icon {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-bar-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
    overflow: hidden;
}

.event-bar {
    height: 4px;
    border-radius: 2px;
    width: 100%;
}

/* Floating Pin Tools */
.pin-tools {
    position: fixed;
    left: 95px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 90;
}

.tool-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    color: #888;
}

.tool-btn:hover {
    transform: scale(1.1);
    background: var(--accent-pastel);
}

.tool-btn#btnMasterLock {
    background: #ffffff;
    color: #5d5d5d;
    border: 2px solid transparent;
}

.tool-btn#btnMasterLock.locked {
    background: #eee;
    color: #aaa;
}

.tool-btn#btnMasterLock.unlocked {
    background: var(--accent-pastel);
    color: #2c3e50;
    border-color: #add8e6;
}

.tool-btn.active-copy {
    background: var(--copy-primary) !important;
    color: #4a6d3a !important;
    box-shadow: 0 0 15px rgba(199, 233, 176, 0.6);
    animation: pulse-green 1.5s infinite;
}

.tool-btn.active-delete {
    background: #ff4d4d !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.5);
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-green {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(142, 180, 134, 0.4);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes pulse-red {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Modal & Forms */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 95%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid #eee;
    outline: none;
    transition: 0.3s;
}

.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-pastel);
    color: #444;
}

.btn-secondary {
    background: var(--secondary-pastel);
    color: #444;
}

.btn-danger {
    background: var(--danger-pastel);
    color: white;
}

.time-blocks,
.note-blocks,
.deadline-blocks {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 5px;
}

.time-block,
.note-block,
.deadline-block {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--secondary-pastel);
    margin-bottom: 10px;
    border-radius: 12px;
    border-left: 8px solid var(--accent-pastel);
    transition: all 0.3s ease;
}

.deadline-block {
    border-left: 8px solid var(--deadline-color);
}

.block-time {
    width: 110px !important;
    flex-shrink: 0;
    padding: 8px !important;
}

.block-title,
.block-note-text {
    flex: 1;
    border: none !important;
    background: rgba(255, 255, 255, 0.7) !important;
    padding: 8px !important;
    border-radius: 8px !important;
    font-size: 0.95rem;
    outline: none;
}

.block-note-text {
    min-height: 80px;
    resize: vertical;
}

.color-picker {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.1);
    transition: 0.2s;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-swatch.active {
    border-color: #555;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.color-swatch.custom-picker {
    background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
    border: 2px dashed #ccc;
    color: white;
}

.custom-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: 0;
    transform: scale(3);
}

.hidden {
    display: none !important;
}

.dashboard-event-item,
.dashboard-note-item,
.dashboard-deadline-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 12px;
    background: #fafafa;
    border-left: 12px solid #ddd;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.03);
}

.dashboard-deadline-item {
    background: #fff;
    justify-content: space-between;
}

.dashboard-note-item {
    align-items: flex-start;
    white-space: pre-wrap;
    border-left: 12px solid #ddd;
}

.quick-edit-btn {
    width: 35px;
    height: 35px;
    border-radius: 10px;
    background: var(--secondary-pastel);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    color: var(--text-color);
}

.event-time-tag {
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.6);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: bold;
}

.deadline-count-tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
    background: var(--deadline-color);
}

.dash-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

#toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    opacity: 0;
    transition: 0.3s;
    pointer-events: none;
    z-index: 2000;
    text-align: center;
    min-width: 200px;
}

#toast.show {
    opacity: 1;
    bottom: 40px;
}

/* Schedule List Styles */
.schedule-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #eee;
    transition: 0.2s;
}

.schedule-item:hover {
    background-color: #f9f9f9;
}

/* Toggle Button for Checkbox in Modal */
.btn-toggle-list {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: white;
    border: 1px solid #ddd;
    color: #666;
    transition: 0.2s;
    margin-top: 5px;
}

.btn-toggle-list.active {
    background: var(--copy-primary);
    color: #2c3e50;
    border-color: #8eb486;
}

/* Progress */
.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 15px 0 25px 0;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #a8e6cf, #81c784);
    border-radius: 999px;
    transition: width 0.4s ease;
}

#progressText {
    font-weight: 700;
    font-size: 1.05rem;
    color: #333;
    min-width: 45px;
}

.summary-progress-card {
    margin-top: 10px;
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    justify-content: flex-end;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.progress-bar {
    width: 100%;
    height: 14px;
    background: #2b2b2b;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

#progressFill {
    height: 100%;
    width: 0%;
    border-radius: 10px;
    background: linear-gradient(
        135deg,
        #00c6ff,
        #0072ff
    );
    transition: width 0.4s ease;
}

/* 📅 พื้นหลังตัวเลขวันที่เป็นขาวอมเทา */
.summary-date-top input[type="date"] {
    padding: 10px 18px;
    border-radius: 30px;
    border: 1.5px solid #d6d6d6;
    background-color: #f3f3f3;   /* ขาวอมเทา */
    color: #333;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

/* Hover */
.summary-date-top input[type="date"]:hover {
    background-color: #ececec;
}

/* Focus */
.summary-date-top input[type="date"]:focus {
    background-color: #ffffff;
    border-color: #bdbdbd;
    outline: none;
}

.day-pie-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 5px;
}

.day-pie {
    width: 50px !important;
    height: 50px !important;
}

/* =========================
   📱 MOBILE RESPONSIVE
========================= */

@media (max-width: 768px) {

    body {
        flex-direction: column;
    }

    /* Sidebar → กลายเป็น Bottom Bar */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        flex-direction: row;
        justify-content: space-around;
        padding: 0;
        border-right: none;
        border-top: 2px solid #f0e4e4;
        z-index: 999;
    }

    .sidebar-item {
        margin: 0;
        width: 45px;
        height: 45px;
    }

    .sidebar-item .tooltip {
        display: none; /* ซ่อน tooltip บนมือถือ */
    }

    /* Main Content */
    .main-container {
        padding: 20px;
        padding-bottom: 90px; /* เว้นพื้นที่ให้ bottom bar */
    }

    header {
        text-align: center;
    }

    .clock-container {
        font-size: 1.6rem;
    }

    .date-display {
        font-size: 0.9rem;
    }

    /* Dashboard grid → 1 คอลัมน์ */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Calendar */
    .calendar-grid {
        gap: 6px;
    }

    .calendar-day {
        min-height: 70px;
        padding: 4px;
    }

    .day-number {
        font-size: 0.75rem;
    }

    .day-pie {
        width: 40px !important;
        height: 40px !important;
    }

    /* Floating Pin Tools → ย้ายมุมขวาล่าง */
    .pin-tools {
        left: auto;
        right: 15px;
        top: auto;
        bottom: 90px;
        transform: none;
        flex-direction: column;
    }

    .tool-btn {
        width: 42px;
        height: 42px;
    }

    /* Modal ปรับให้เต็มจอมากขึ้น */
    .modal-content {
        width: 95%;
        max-height: 85vh;
        padding: 20px;
        border-radius: 18px;
    }

    /* Time block ให้เรียงแนวตั้ง */
    .time-block,
    .note-block,
    .deadline-block {
        flex-direction: column;
        gap: 10px;
    }

    .block-time {
        width: 100% !important;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

}