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

:root {
    --primary-color: #3b82f6;
    --text-color: #333;
    --bg-color: #ffffff;
    --border-color: #e5e7eb;
    --hover-color: #f9fafb;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #ffffff;
        --bg-color: #1a1a1a;
        --border-color: #4b5563;
        --hover-color: #2d3748;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.app {
    display: flex;
    height: 100vh;
}

/* 사이드바 스타일 */
.sidebar {
    width: 350px;
    background: white;
    padding: 1rem;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100vh; /* 전체 높이 사용 */
    overflow: hidden; /* 사이드바 전체는 스크롤 없음 */
}

/* 사이드바 감추기/보이기 관련 스타일 */
.sidebar.hidden {
    display: none;
}

.toggle-btn {
    padding: 0.375rem 0.75rem;
    margin-right: 0.5rem;
    min-width: 40px;
}

.sidebar-icon {
    font-style: normal;
    font-weight: bold;
}

/* 사이드바가 숨겨졌을 때 토글 버튼 아이콘 변경 */
.sidebar.hidden + .resizer + .main-content .sidebar-icon {
    transform: rotate(180deg);
    display: inline-block;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: bold;
    text-align: left;
    margin: 0;
    flex-basis: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

#categoryFilter {
    width: 150px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: white;
}

#addScheduleBtn {
    flex-basis: 30%;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#addScheduleBtn:hover {
    background-color: #2563eb;
}

.schedule-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto; /* 리스트만 세로 스크롤 가능 */
    flex-grow: 1; /* 남은 공간 모두 차지 */
    padding-right: 0.5rem; /* 스크롤바 공간 확보 */
}

.schedule-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.list-title {
    font-size: 1.25rem;
    font-weight: bold;
}

.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.add-btn:hover {
    background-color: #2563eb;
}

.schedule-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none; /* 텍스트 선택 방지 */
}

.schedule-card:hover {
    background-color: #f9fafb;
}

.schedule-card.highlighted {
    background-color: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.schedule-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.schedule-number {
    font-weight: 600;
    font-size: 0.875rem;
    color: #6b7280;
    min-width: 1.5rem;
    text-align: center;
    background: #f3f4f6;
    border-radius: 50%;
    padding: 0.1rem 0.4rem;
}



.schedule-title {
    font-weight: 600;
    flex-grow: 1;
}

.schedule-date {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.schedule-category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-left: 0.25rem;
}

.category-badge {
    font-size: 0.875rem;
    letter-spacing: 0.025em;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 6px;
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}

.delete-btn {
    padding: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.75rem;
    opacity: 0.7;
    border-radius: 0.25rem;
}

.delete-btn:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
    opacity: 1;
}

/* 리사이저 스타일 - 숨김 처리 */
.resizer {
    width: 0;
    background: transparent;
    display: none;
}

/* 메인 콘텐츠 스타일 */
.main-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 캘린더 헤더 컨테이너 스타일 */
.calendar-header-container {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bg-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* 캘린더 헤더 스타일 */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.calendar-title-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
    min-width: 300px;
}

.calendar-title-area #addScheduleBtn {
    margin-right: 0.5rem;
    min-width: 100px;
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

.calendar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0;
}

.add-schedule-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-schedule-btn:hover {
    background-color: #2563eb;
}

.calendar-actions {
    display: flex;
    gap: 0.5rem;
}

/* 모두 삭제 버튼 스타일 */
#clearSchedulesBtn {
    margin-left: 20px;
}

/* 캘린더 컨테이너 스타일 */
.calendar-container {
    flex: 1;
    overflow-y: auto;
}

.action-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: #2563eb;
}

.danger-btn {
    background-color: #ef4444;
}

.danger-btn:hover {
    background-color: #dc2626;
}

.calendar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.month-container {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    background: var(--bg-color);
    overflow-x: hidden;
    width: 100%;
    --days-in-month: 31; /* 기본값 */
}

.month-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.days-grid {
    display: flex;
    gap: 0;
    position: relative;
    overflow: visible;
    min-height: 150px;
    flex-wrap: nowrap;
    width: 100%;
}

.day-cell {
    flex: 0 0 calc(100% / var(--days-in-month));
    min-height: 100px;
    border: 0px solid var(--border-color);
    border-right: 1px solid #e5e7eb;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.day-cell:last-child {
    border-right: 0;
}

.day-number {
    font-weight: 500;
    margin-bottom: 0.5rem;
    z-index: 1;
    height: 20px;
    padding-left: 5px;
    border-bottom: none;
}

/* 요일 색상 */
.day-number.sunday {
    color: #f74141;
    font-weight: bold;
}

.day-number.saturday {
    color: #4185f7;
    font-weight: bold;
}

.schedules-container {
    flex: 1;
    position: relative;
    min-height: 22px;
    overflow: visible;
    padding-bottom: 4px;
}

.schedule-line {
    height: 20px;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: visible;
    transition: all 0.2s;
    position: absolute;
    left: 0;
    right: 0;
    margin: 1px 2px;
    z-index: 2; /* 기본 z-index */
    min-width: 50px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    user-select: none; /* 텍스트 선택 방지 */
}

/* 마우스 오버시 앞으로 나오게 함 */
.schedule-line:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 100 !important; /* 호버 시 최상위로 */
    cursor: grab; /* 잡을 수 있는 커서로 변경 */
}

/* 드래그 중인 일정 스타일 */
.schedule-line.dragging {
    cursor: grabbing !important; /* 잡은 상태의 커서 */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
    transition: transform 0.1s, box-shadow 0.1s;
    opacity: 0.9;
}

/* 일정 이동 모드 스타일 (schedule-day에서 참고) */
.schedule-line.dragging-to-move {
    cursor: grabbing !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
    transition: transform 0.2s, box-shadow 0.2s;
    opacity: 0.85;
    border: 2px solid #4285f4;
    z-index: 100 !important;
}

/* 드래그 타겟 날짜 셀 하이라이트 */
.day-cell.drag-target {
    background-color: rgba(66, 133, 244, 0.1);
    border: 2px dashed #4285f4;
    border-radius: 8px;
    transition: all 0.2s ease;
}

/* 드래그 타겟 날짜 셀의 날짜 번호 스타일 */
.day-cell.drag-target .day-number {
    color: #4285f4;
    font-weight: bold;
    background-color: rgba(66, 133, 244, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
}

/* 드래그 호버 효과 (schedule-day에서 참고) */
.day-cell.drag-hover {
    background-color: rgba(34, 197, 94, 0.1);
    border: 2px solid #22c55e;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.day-cell.drag-hover .day-number {
    color: #22c55e;
    font-weight: bold;
    background-color: rgba(34, 197, 94, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
}

/* 드래그 중 일정이 고정 위치에 있을 때 부드러운 애니메이션 */
.schedule-line[style*="position: fixed"] {
    transition: none !important; /* 드래그 중에는 transition 제거 */
    border-radius: 6px;
    backdrop-filter: blur(2px);
}

.schedule-line-resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background-color 0.2s;
}

.schedule-line-resizer:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.schedule-line-resizer.active {
    background-color: rgba(0, 0, 0, 0.2);
}

.schedule-line-text {
    text-align: left;
    display: inline-block;
    width: 100%;
    overflow: visible;
    white-space: nowrap;
    text-overflow: clip;
    padding-left: 0.25rem;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

#scheduleForm {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#scheduleForm input,
#scheduleForm select,
#scheduleForm textarea {
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

#scheduleForm textarea {
    min-height: 100px;
    resize: vertical;
}

/* 모달 폼 레이아웃 */
.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.reminder-setting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    margin-left: 20px;
}

.color-setting {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.2rem;
    width: auto;
    margin-left: 0.5rem;
}

#scheduleCategory {
    flex: 0.5;
}

.color-setting label {
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* 모달 버튼 스타일 */
.modal-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    align-items: center;
}

.left-buttons {
    display: flex;
    gap: 10px;
}

.center-buttons {
    display: none;
}

.right-buttons {
    display: flex;
    gap: 10px;
}

/* 저장 버튼 */
#saveScheduleBtn {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#saveScheduleBtn:hover {
    background-color: #2563eb;
}

/* 취소 버튼 */
#cancelScheduleBtn {
    background-color: #e5e7eb;
    color: #1f2937;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#cancelScheduleBtn:hover {
    background-color: #d1d5db;
}

/* 스케줄 색상 선택 */
#scheduleColor {
    width: 55px;
    height: 2.8rem;
    padding: 0;
    border: none;
    cursor: pointer;
    border-radius: 0.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

#scheduleColor:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 버튼 스타일 */
.edit-btn,
.delete-btn {
    padding: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
}

.edit-btn:hover,
.delete-btn:hover {
    color: #374151;
}

/* 접근성 개선 */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 미디어 쿼리 */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .month-container {
        margin-bottom: 1rem;
    }
    
    .day-cell {
        width: 1.2rem;
        min-height: 4rem;
    }
    
    .schedule-line {
        width: 150px;
    }
    
    .calendar-title-area {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.5rem;
        min-width: auto;
    }
    
    .calendar-title-area #addScheduleBtn {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 0.5rem;
    }
    
    .day-cell {
        width: 1rem;
        min-height: 3rem;
    }
    
    .schedule-line {
        width: 100px;
    }
}

/* 버튼 공통 스타일 */
button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

/* 사이드바 버튼 */
#addScheduleBtn {
    background: var(--primary-color);
    color: white;
}

#addScheduleBtn:hover {
    background: #2563eb;
}

/* 로깅용 스타일 */
.debug-info {
    position: absolute;
    right: 5px;
    top: 5px;
    font-size: 9px;
    color: rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.no-results-message {
    padding: 1rem;
    text-align: center;
    color: #6b7280;
    font-style: italic;
    border: 1px dashed #e5e7eb;
    border-radius: 0.5rem;
    margin: 1rem 0;
    background-color: #f9fafb;
}

/* 반복 일정 표시용 스타일 */
.repeat-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: var(--primary-color);
  opacity: 0.8;
}

.schedule-card[data-is-recurring="true"],
.schedule-card[data-is-recurring-instance="true"] {
  border-left: 3px solid var(--primary-color);
}

.repeat-info {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.25rem;
  font-style: italic;
}

/* 반복 일정 편집 모달 스타일 */
.recurring-edit-options {
    padding: 1rem;
}

.recurring-edit-options p {
    margin-bottom: 1rem;
    font-size: 1rem;
    text-align: center;
}

.option-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.edit-option-btn {
    background: #f3f4f6;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.edit-option-btn:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.edit-option-btn.cancel-btn {
    background: #e5e7eb;
    margin-top: 0.5rem;
    text-align: center;
}

.edit-option-btn.cancel-btn:hover {
    background: #d1d5db;
}

.option-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* 삭제 버튼 */
#deleteScheduleBtn {
    background-color: #ef4444;
    color: white;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#deleteScheduleBtn:hover {
    background-color: #dc2626;
}

.edit-option-btn.delete-option-btn {
    background-color: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}

.edit-option-btn.delete-option-btn:hover {
    background-color: #fecaca;
} 

/* 선택된 날짜 셀 스타일 */
.day-cell.selected {
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
} 

.sidebar-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sidebar-view-options {
    flex: 0 0 auto;
}

.view-option-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    min-width: 100px;
}

.view-option-btn:hover {
    background-color: #2563eb;
}

.toggle-icon {
    font-size: 0.75rem;
}

.sidebar-filter {
    flex: 1;
    display: flex;
    justify-content: flex-end;
} 

.day-cell.today {
    background-color: rgba(154, 247, 159, 0.1); /* 연한 푸른색 배경 */
    border: 1px solid rgba(59, 130, 246, 0.3); /* 연한 푸른색 테두리 */
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2); /* 내부 그림자 효과 */
} 

/* 반복 설정 관련 스타일 */
.repeat-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.warning-text {
    color: #ff0000;
    font-size: 0.85em;
    font-weight: bold;
}

.custom-repeat-options {
    background-color: #f3f4f6;
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.custom-repeat-options .form-row {
    margin-bottom: 10px;
}

.custom-repeat-options label {
    min-width: 100px;
    font-weight: 500;
}

.weekday-selector, .month-day-selector {
    margin-top: 10px;
}

.weekday-checkboxes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: 10px;
}

.weekday-checkboxes label {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    font-weight: normal;
    min-width: auto;
}

.weekday-checkboxes input[type="checkbox"] {
    margin-right: 3px;
}

#repeatIntervalUnit {
    margin-left: 5px;
    font-weight: 500;
    color: #6b7280;
}

#repeatType, #repeatInterval, #repeatEndType, #repeatCount, #repeatUntil, #repeatMonthType {
    padding: 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

#repeatInterval, #repeatCount {
    width: 80px;
}

/* 반복 일정 표시용 스타일 */
.repeat-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    color: var(--primary-color);
    opacity: 0.8;
}

.schedule-card.repeated-schedule {
    border-left: 3px solid var(--primary-color);
}

.repeat-info {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
    font-style: italic;
} 