/* --- 기본 & 변수 시스템 --- */
:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #f0f0f0;
    --item-bg: #f8f9fa;
    --item-hover: #e9ecef;
    --completed-bg: linear-gradient(135deg, #667eea15, #764ba215);
    font-size: 16px;
}

body.dark-mode {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --card-bg: #0f3460;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #2d3748;
    --item-bg: #1e3a5f;
    --item-hover: #2d4a6f;
    --completed-bg: linear-gradient(135deg, #667eea30, #764ba230);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    transition: background 0.5s ease, color 0.5s ease;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* --- 헤더 --- */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    animation: fadeInDown 0.8s ease;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
}

.header h1 {
    font-size: 2.5em;
    font-weight: bold;
    margin: 0; /* 헤더 버튼과의 정렬을 위해 수정 */
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 20px;
}

.header-buttons {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,0.3);
}


.date-display {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 1em;
    font-weight: 500;
}

/* --- 리워드 대시보드 --- */
.reward-dashboard {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    animation: fadeInUp 1s ease;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-header h3 {
    color: var(--text-primary);
    font-size: 1.4em;
    margin: 0;
}

.email-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.email-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.reward-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.reward-card {
    display: flex;
    align-items: center;
    padding: 20px;
    background: var(--item-bg);
    border-radius: 15px;
    transition: all 0.3s ease;
}

.reward-card:hover {
    transform: translateY(-3px);
    background: var(--item-hover);
}

.reward-icon {
    font-size: 2.5em;
    margin-right: 15px;
}

.reward-info {
    flex: 1;
}

.reward-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.reward-amount {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-primary);
}


/* --- 카테고리 --- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.category-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.8s ease;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
}

.category-header {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.category-icon {
    font-size: 2.5em;
    margin-right: 15px;
}

.category-title h2 {
    color: var(--text-primary);
    font-size: 1.5em;
    margin-bottom: 5px;
}

.category-progress {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.category-progress-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 10px 0;
}

.mini-progress-container {
    flex: 1;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.5s ease;
    border-radius: 6px;
}

.progress-percentage {
    font-size: 0.9em;
    font-weight: bold;
    color: var(--text-primary);
    min-width: 45px;
    text-align: right;
}


/* --- To-Do 항목 --- */
.todo-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 10px;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 12px;
    background: var(--item-bg);
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.todo-item:hover {
    background: var(--item-hover);
    transform: translateX(5px);
}

.todo-item.completed {
    background: var(--completed-bg);
}

.custom-checkbox {
    width: 28px;
    height: 28px;
    border: 2px solid #667eea;
    border-radius: 8px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.custom-checkbox.checked {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: transparent;
}

.custom-checkbox.checked::after {
    content: '✓';
    color: white;
    font-weight: bold;
    font-size: 1.2em;
}

.todo-label {
    flex: 1;
    font-size: 1.05em;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.todo-item.completed .todo-label {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.photo-upload-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s ease;
    margin-left: 10px;
    white-space: nowrap;
}

.photo-upload-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.photo-upload-btn.uploaded {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

input[type="file"] {
    display: none;
}

/* --- 알림 --- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    z-index: 1001;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.error {
    border-left: 4px solid #f44336;
}

.notification.success {
    border-left: 4px solid #4CAF50;
}

/* --- 모달 공통 --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: fadeInUp 0.4s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 1.5em;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--item-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 25px;
    line-height: 1.6;
    overflow-y: auto;
}

/* --- 이메일 모달 --- */
.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}
.modal-body strong {
    color: var(--text-primary);
    font-weight: 600;
}
.email-preview {
    background: var(--item-bg);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}
.preview-section h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
}
.preview-section p {
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}
.cancel-btn, .send-btn {
    padding: 12px 25px;
    border-radius: 25px;
    border: none;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}
.cancel-btn {
    background: var(--item-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.cancel-btn:hover { background: var(--item-hover); }
.send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}
.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* --- 캘린더 모달 --- */
.calendar-modal .modal-content { max-width: 800px; }
.calendar-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.nav-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
}
.nav-btn:hover { transform: scale(1.1); }
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 25px;
}
.calendar-day-header {
    text-align: center;
    font-weight: bold;
    color: var(--text-secondary);
    padding-bottom: 10px;
    font-size: 0.9em;
}
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--item-bg);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    padding: 8px;
    border: 2px solid transparent;
}
.calendar-day:hover { transform: scale(1.05); }
.calendar-day.today { border-color: #667eea; }
.calendar-day.selected {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white !important;
    transform: scale(1.05);
}
.calendar-day.selected .calendar-day-number,
.calendar-day.selected .calendar-day-completion { color: white; }
.calendar-day.has-data::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #667eea;
}
.calendar-day.selected.has-data::after { background-color: white; }
.calendar-day.empty { background: transparent; cursor: default; }
.calendar-day.empty:hover { transform: none; }
.calendar-day-number { font-size: 1em; font-weight: 600; color: var(--text-primary); }
.calendar-day-completion { font-size: 0.7em; margin-top: 2px; color: var(--text-secondary); }

.selected-date-info {
    background: var(--item-bg);
    border-radius: 15px;
    padding: 20px;
    min-height: 150px;
}
.info-placeholder { text-align: center; color: var(--text-secondary); padding-top: 40px;}
.date-detail { animation: fadeIn 0.3s ease; }
.date-detail h4 { color: var(--text-primary); font-size: 1.3em; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }
.detail-section { margin-bottom: 20px; }
.detail-section h5 { color: #667eea; font-size: 1.1em; margin-bottom: 10px; }
.detail-item { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--card-bg); border-radius: 8px; margin-bottom: 8px; }
.detail-item.completed { opacity: 0.7; }
.detail-item.completed .item-name { text-decoration: line-through; }
.reward-highlight { background: linear-gradient(135deg, #f6d365, #fda085); color: white; padding: 15px; border-radius: 10px; text-align: center; font-size: 1.2em; font-weight: bold; margin-bottom: 15px; }


/* --- 폭죽 효과 --- */
#fireworksCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}
#fireworksCanvas.active { display: block; }


/* --- 애니메이션 --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* --- 반응형 디자인 --- */
@media (max-width: 1024px) {
    .container { padding: 0 15px; }
    .category-grid { grid-template-columns: 1fr 1fr; gap: 20px; }
    .header h1 { font-size: 2.2em; }
    .category-card { padding: 25px; }
}

@media (max-width: 768px) {
    body { padding: 15px; }
    .header h1 { font-size: 1.5em; }
    .header-top { justify-content: space-between; }
    .header-buttons { position: static; transform: none; }
    .reward-stats { grid-template-columns: 1fr; }
    
    .modal { padding: 10px; }
    .modal-content { width: 100%; max-height: 90vh; }
    .modal-header h2 { font-size: 1.3em; }
    .modal-body { padding: 20px 15px; }
    .modal-footer { padding: 15px; flex-direction: column-reverse; gap: 15px; }
    .cancel-btn, .send-btn { width: 100%; }

    .calendar-modal .modal-content { max-width: 100%; }
    .calendar-navigation h3 { font-size: 1.2em; }
    .nav-btn { width: 35px; height: 35px; font-size: 1em; }
    .calendar-grid { gap: 6px; }
    .calendar-day-header { font-size: 0.85em; }
    .calendar-day { padding: 6px; }
    .calendar-day-number { font-size: 0.9em; }
    .calendar-day-completion { font-size: 0.65em; }
    .selected-date-info { padding: 15px; min-height: 150px; }
    .date-detail h4 { font-size: 1.1em; }
    .detail-section h5 { font-size: 1em; }
    .reward-highlight { font-size: 1em; padding: 12px; }
}

@media (max-width: 480px) {
    body { padding: 10px; }
    .header h1 { font-size: 1.4em; }
    .icon-btn { width: 45px; height: 45px; font-size: 1.3em; }
    .email-btn { padding: 10px 18px; font-size: 0.9em; }
    .reward-card { padding: 15px; }
    .reward-icon { font-size: 2em; }
    .reward-amount { font-size: 1.1em; }

    .calendar-navigation h3 { font-size: 1.1em; }
    .nav-btn { width: 32px; height: 32px; font-size: 0.9em; }
    .calendar-grid { gap: 4px; }
    .calendar-day-header { font-size: 0.75em; }
    .calendar-day { padding: 4px; border-radius: 6px; }
    .calendar-day-number { font-size: 0.85em; }
    .calendar-day-completion { font-size: 0.6em; }
    .calendar-day.has-data::after { font-size: 1.2em; bottom: 2px; }
    .selected-date-info { padding: 12px; }
    .date-detail h4 { font-size: 1em; }
    .detail-section h5 { font-size: 0.95em; }
    .detail-item { padding: 6px 10px; font-size: 0.9em; }
    .reward-highlight { font-size: 0.95em; padding: 10px; }
}

@media (max-height: 600px) and (orientation: landscape) {
    .calendar-modal .modal-content { max-height: 95vh; }
    .selected-date-info { max-height: 180px; overflow-y: auto; }
}

@media (hover: none) and (pointer: coarse) {
    .icon-btn:hover,
    .email-btn:hover,
    .send-btn:hover,
    .reward-card:hover,
    .category-card:hover,
    .todo-item:hover,
    .calendar-day:hover,
    .nav-btn:hover { transform: none; box-shadow: none; }
}
