* {
    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: #3a3a3a;
    }
}

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: 400px;
    background: var(--bg-color);
    padding: 1rem;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100vh; /* 전체 높이 사용 */
    overflow: hidden; /* 사이드바 전체는 스크롤 없음 */
    transition: all 0.3s ease;
}

/* 사이드바 토글 관련 스타일 */
.toggle-btn {
    padding: 0.375rem 0.75rem;
    margin-left: 0.5rem;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
}

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

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* 사이드바 숨김 상태 */
.app.sidebar-hidden .sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
}

.app.sidebar-hidden .resizer {
    display: none;
}

.app.sidebar-hidden .toggle-icon {
    transform: rotate(180deg);
}

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

.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: 35%;
}

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

#categoryFilter {
    width: 100%;
    max-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; /* 스크롤바 공간 확보 */
}

/* 리사이저 스타일 */
.resizer {
    display: none; /* 리사이저 비활성화 */
}

/* 캘린더 헤더 컨테이너 스타일 */
.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;
    font-size: 1.1rem;
}

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

/* 미디어 쿼리 */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
        transition: all 0.3s ease;
    }
    
    .app.sidebar-hidden .sidebar {
        max-height: 0;
    }
    
    .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: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.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: 1.1rem;
    transition: background-color 0.2s;
}

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

.schedule-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.schedule-card:hover {
    background-color: var(--hover-color);
}

.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-color {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
}

.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: 2px 4px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.05);
    margin-left: auto;
    text-align: right;
}

.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;
}

.add-schedule-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 1.1rem;
    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: 1.1rem;
    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%;
    margin-bottom: 0.5rem;
}

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

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    position: relative;
    overflow: visible;
    min-height: 150px;
    width: 100%;
}

.day-cell {
    min-height: 100px;
    border: 1px solid var(--border-color);
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.day-cell.empty {
    background-color: var(--hover-color);
    opacity: 0.5;
}

.day-number {
    font-weight: 500;
    margin-bottom: 0.5rem;
    z-index: 1;
    height: 20px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background-color: var(--bg-color);
    border-bottom: none;
}

.day-number .weekday {
    font-size: 0.8rem;
    color: #6b7280;
    margin-right: 5px;
}

.day-number .day-num {
    font-size: 0.9rem;
}

.day-number .day-num.saturday {
    color: #3b82f6;
}

.day-number .day-num.sunday {
    color: #ef4444;
}

.day-number .day-num.today {
    background-color: #8b5cf6;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.schedules-container {
    flex: 1;
    position: relative;
    min-height: 22px;
    overflow: visible;
    padding: 4px;
    margin-top: 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: 4px;
    right: 4px;
    margin: 1px 0;
    z-index: 2;
    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;
    top: 0;
}

.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;
}

.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: var(--bg-color);
    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 {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.form-row label {
    margin-right: 10px;
    min-width: 80px;
}

.form-row.date-row {
    gap: 1rem;
}

.form-row.date-row label {
    min-width: 4rem;
    font-weight: 500;
}

.form-row.date-row input[type="date"] {
    width: 8rem;
    flex: 0 0 auto;
    padding-right: 2rem;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
}

.form-row.date-row input[type="date"]::-webkit-datetime-edit {
    padding: 0;
}

.form-row.date-row input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    width: 2rem;
    height: 2rem;
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
}

.form-row.date-row input[type="date"]::before {
    content: '📆';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    pointer-events: none;
}

/* 달력 월 이동 화살표 스타일 */
input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-clear-button {
    display: none;
}

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

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

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

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

.weekday-checkboxes label {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
}

#repeatIntervalUnit {
    margin-left: 5px;
}

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

.color-setting {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.color-setting label {
    font-weight: 500;
    color: var(--text-color);
    min-width: 4rem;
}

/* 반복 일정 스타일 */
.repeated-schedule {
    border-left: 3px solid #3b82f6;
}

.repeat-icon {
    font-size: 0.85em;
    margin-left: 5px;
    opacity: 0.8;
}

/* 버튼 스타일 */
.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;
}

/* 로깅용 스타일 */
.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;
}

/* 반복 일정 표시용 스타일만 CSS 파일에 유지 */
.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;
}

.category-setting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: nowrap;
}

.category-setting label {
    font-weight: 500;
    min-width: 4rem;
    white-space: nowrap;
}

.category-select-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

#scheduleCategory {
    flex: 1;
    min-width: 100px;
    max-width: 200px;
}

.small-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

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

.category-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 1rem 0;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.category-item-color {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

.category-item-name {
    flex-grow: 1;
}

.category-item-actions {
    display: flex;
    gap: 0.25rem;
}

.add-category-form {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.add-category-form input[type="text"] {
    flex-grow: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
}

.add-category-form input[type="color"] {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
}

/* 달력 월 이동 화살표 방향 변경 */
input[type="date"]::-webkit-calendar-picker-indicator {
    transform: rotate(90deg);
}

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

.center-buttons {
    display: flex;
    gap: 0.75rem;
}

#saveScheduleBtn {
    background: #3b82f6;
    color: white;
}

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

#cancelScheduleBtn {
    background: #e5e7eb;
    color: #374151;
}

#cancelScheduleBtn:hover {
    background: #d1d5db;
}

#deleteScheduleBtn {
    background: #ef4444;
    color: white;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

#deleteScheduleBtn:hover {
    background: #dc2626;
}

/* 스케줄 색상 선택 */
#scheduleColor {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    flex-shrink: 0;
}

#scheduleColor::-webkit-color-swatch-wrapper {
    padding: 0;
}

#scheduleColor::-webkit-color-swatch {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#scheduleColor:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#scheduleColor:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 커스텀 알림 모달 스타일 */
.custom-alert-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.custom-alert-modal.active {
    display: flex;
}

.custom-alert-content {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

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

.custom-alert-content p {
    margin-bottom: 1.5rem;
}

.custom-alert-content button {
    background: var(--primary-color);
    color: white;
}

.custom-alert-content button:hover {
    background: #2563eb;
} 