:root {
    --primary-color: #4a90e2;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --completed-color: #2ecc71;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --modal-radius: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    touch-action: manipulation;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-bottom: 80px; 
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

header { margin-bottom: 20px; }

.header-top {
    display: flex;
    flex-direction: column; 
    gap: 15px;
    margin-bottom: 15px;
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
    text-align: center;
}

/* User Chips */
.user-chips {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-chip {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: white;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-chip.active {
    background-color: var(--primary-color);
    color: white;
}

.user-chip:active { transform: scale(0.95); }

.chip-badge {
    background-color: #e74c3c;
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    display: none;
}

.user-chip.active .chip-badge {
    background-color: white;
    color: var(--primary-color);
    font-weight: bold;
}

/* Date Navigator */
.date-navigator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 10px;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    padding: 5px 15px;
    cursor: pointer;
}

.date-display {
    text-align: center;
    position: relative;
    flex: 1;
    cursor: pointer; 
    padding: 5px;
}

#date-text {
    font-weight: 500;
    font-size: 1.1rem;
    color: #333;
    pointer-events: none;
}

/* Week Strip */
.week-strip {
    display: flex;
    justify-content: space-between;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.week-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px 5px;
    border-radius: 8px;
    width: 13.5%; 
    transition: background-color 0.2s;
}

.week-day:hover { background-color: #f5f7fa; }

.week-day.active {
    background-color: var(--primary-color);
    color: white;
}

.week-day-name {
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: #888;
}

.week-day.active .week-day-name { color: rgba(255,255,255,0.9); }

.week-day-number {
    font-size: 1rem;
    font-weight: 600;
}

.week-day-dot {
    width: 5px;
    height: 5px;
    background-color: #e74c3c;
    border-radius: 50%;
    margin-top: 4px;
    opacity: 0;
}

.week-day-dot.has-task { opacity: 1; }
.week-day.active .week-day-dot { background-color: white; }

/* Todo List */
.todo-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.todo-card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
    border-left: 5px solid transparent; 
}

.todo-card[data-priority="Critical"] {
    border-left-color: #e74c3c; 
    background-color: #fdedec;
}
.todo-card[data-priority="High"] {
    border-left-color: #f39c12; 
    background-color: #fef5e7;
}
.todo-card[data-priority="Low"] {
    border-left-color: #2ecc71; 
}

.todo-card.completed {
    background-color: #e8f8f5;
    opacity: 0.8;
    border-left-color: #bdc3c7; 
}
.todo-card.completed[data-priority] { background-color: #e8f8f5; }

.todo-info { flex: 1; }

.todo-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}

.todo-card.completed .todo-title {
    text-decoration: line-through;
    color: #888;
}

.todo-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    gap: 10px;
}

.todo-check {
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-radius: 50%;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.todo-card.completed .todo-check {
    background-color: var(--completed-color);
    border-color: var(--completed-color);
    color: white;
}

.delete-btn {
    background: none;
    border: none;
    color: #e74c3c;
    padding: 10px;
    cursor: pointer;
    opacity: 0.5;
}
.delete-btn:hover { opacity: 1; }

/* FAB */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    z-index: 900;
}
.fab:active { transform: scale(0.95); }

/* Modal General */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6); /* Darker backdrop */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px); /* Blur effect */
    opacity: 1;
    transition: opacity 0.3s;
}

.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background: white;
    border-radius: var(--modal-radius);
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

/* Task Modal Specific */
.task-modal {
    padding: 0;
}

.modal-header {
    padding: 15px 25px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: center; /* Center content */
    align-items: center;
    position: relative; /* For absolute positioning of close button */
}

/* Header Date Input */
.modal-date-wrapper {
    display: flex;
    align-items: center;
    gap: 4px; 
    position: relative;
    cursor: pointer;
}

.modal-title-date {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    outline: none;
    font-family: inherit;
    cursor: pointer;
    padding: 0; 
    margin: 0;
    text-align: center; /* Center text */
}

/* Fix for date input on iOS/Mobile to look more like text */
.modal-title-date::-webkit-datetime-edit { 
    padding: 0; 
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
    position: absolute; /* Absolute position */
    right: 20px;
}
.close-btn:hover { color: #333; }

#add-form {
    padding: 25px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    font-size: 1rem;
    background-color: #fcfcfc;
    transition: all 0.2s;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    border-color: var(--primary-color);
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 針對時間選擇器的特別處理 (部分瀏覽器可能需要) */
.form-group input[type="time"] {
    line-height: normal; /* 重置 line-height */
    width: 100%; /* Fill container */
}

.form-group textarea {
    resize: none;
}

.form-row {
    display: flex;
    gap: 10px; /* Reduced gap to save space */
}

.form-group.half:first-child {
    flex: 0 0 auto; 
    width: 45%; /* Use percentage instead of fixed min-width */
    min-width: 0; /* Allow shrinking */
}

.form-group.half:last-child {
    flex: 1; 
    min-width: 0; /* Allow shrinking */
}

.modal-footer {
    margin-top: 10px;
}

.btn-primary.full-width {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
}

.btn-primary.full-width:active {
    transform: scale(0.98);
}

/* Calendar Modal Specific */
.calendar-modal-content {
    max-width: 360px;
    padding: 20px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    color: #888;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px; 
    cursor: pointer;
    font-size: 0.95rem;
    position: relative;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.calendar-day:hover { background-color: #f0f4f8; }

.calendar-day.today {
    border: 2px solid var(--primary-color);
    font-weight: 700;
    color: var(--primary-color);
}

.calendar-day.selected {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
}

.calendar-day.empty { pointer-events: none; }

.day-badge {
    background-color: #e74c3c;
    color: white;
    font-size: 0.65rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -2px;
    right: -2px;
    border: 2px solid white;
}

.calendar-day.selected .day-badge {
    background-color: white;
    color: #e74c3c;
    border: none;
}

.loading {
    text-align: center;
    color: #888;
    padding: 20px;
}
