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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.5s ease;
}

.container {
    width: 100%;
    max-width: 1200px;
}

.calendar-wrapper {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    margin: 0 auto;
    width: 1200px;
    max-width: 1200px;
}

.calendar-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.5s ease;
}

/* 자동화 파트 달력 배너 그라데이션 */
body.part2-active .calendar-header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffa500 100%);
}

.calendar-header h1 {
    font-size: 28px;
    font-weight: 600;
}

.calendar-layout {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.side-panel {
    position: absolute;
    top: 50%;
    right: -220px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 200px;
}

.legend-panel {
    position: relative;
    transform: none;
    min-width: 200px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

.legend-title {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    text-align: center;
    margin-bottom: 12px;
}

.color-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-color {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.legend-label {
    font-size: 14px;
    color: #333;
}

.btn-request {
    width: 100%;
    background: #ff7043;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-request:hover {
    background: #ff5722;
    transform: translateY(-1px);
}

#openEventTypeList {
    background: #42a5f5;
}

#openEventTypeList:hover {
    background: #1e88e5;
}

.modal-description {
    margin-bottom: 14px;
    font-size: 14px;
    color: #495057;
}

.request-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.request-item {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #f8f9fa;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.request-item:hover {
    border-color: #667eea;
    background: #eef1ff;
}

.request-item input[type="radio"] {
    margin-top: 4px;
}

.request-item-content {
    flex: 1;
}

.request-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.request-item-detail {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
}

.no-mold-events {
    text-align: center;
    font-size: 14px;
    color: #868e96;
}

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

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

.nav-btn:active {
    transform: scale(0.95);
}

.btn-part-select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-part-select:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.btn-part-select:active {
    transform: translateY(0);
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.weekday {
    padding: 15px;
    text-align: center;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    background: #e9ecef;
    border-top: 1px solid #e9ecef;
    border-left: 1px solid #e9ecef;
}

.day {
    background: white;
    padding: 12px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    position: relative;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    border-right: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
    overflow: visible;
}

.day-number {
    font-weight: 600;
    margin-bottom: 5px;
}

.day-events {
    width: 100%;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
    flex: 1;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.event-item-preview {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 3px solid;
    background: rgba(0, 0, 0, 0.03);
}

.event-item-preview:not(.range-start):not(.range-middle):not(.range-end) {
    width: 100%;
}

.event-item-preview:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.05);
}

.event-item-preview .event-title {
    font-weight: 600;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-item-preview .event-time {
    font-size: 9px;
    opacity: 0.7;
    margin-top: 2px;
    min-height: 12px;
    display: block;
}

.event-more {
    width: 100%;
    padding: 4px;
    text-align: center;
    font-size: 10px;
    color: #6c757d;
    cursor: pointer;
    border-radius: 4px;
    background: rgba(108, 117, 125, 0.1);
    transition: all 0.2s ease;
}

.event-more:hover {
    background: rgba(108, 117, 125, 0.2);
}

.day:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.day.other-month {
    color: #adb5bd;
    background: #f8f9fa;
}

.day.today {
    background: linear-gradient(135deg, #a8d5ff 0%, #e0b3ff 100%);
    color: #333;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(168, 213, 255, 0.4);
    border: 2px solid #667eea;
}

.day.selected {
    background: #28a745;
    color: white;
    font-weight: bold;
}

.day.weekend {
    color: #dc3545;
}

.day.other-month.weekend {
    color: #f1aeb5;
}

/* 기간 일정 스타일 - 완전히 연결된 바 (이미지처럼) */
.event-item-preview.range-start {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-left: -6px;
    margin-right: -1px;
    padding-left: 8px;
    padding-right: 7px;
    width: calc(100% + 7px);
    /* 왼쪽 색상 유지 (기본 border-left 유지) */
}

.event-item-preview.range-end {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    margin-left: -1px;
    margin-right: -6px;
    padding-left: 7px;
    padding-right: 8px;
    width: calc(100% + 7px);
    border-left: none;
    border-right: 3px solid;
}

.event-item-preview.range-middle {
    border-radius: 0;
    margin-left: -1px;
    margin-right: -1px;
    padding-left: 7px;
    padding-right: 7px;
    width: calc(100% + 2px);
    border-left: none;
}

.event-item-preview.range-start.range-end,
.event-item-preview.range-single {
    border-radius: 8px;
    margin-left: -6px;
    margin-right: -6px;
    padding-left: 8px;
    padding-right: 8px;
    width: calc(100% + 12px);
    /* 양쪽 색상 모두 유지 */
    border-right: 3px solid;
}

/* 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

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

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

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px;
}

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

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

.form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: inherit;
}

/* 커스텀 시간 선택기 스타일 */
.custom-time-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-select {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 12px 8px;
    cursor: pointer;
}

.time-separator {
    font-size: 18px;
    font-weight: 600;
    color: #495057;
    user-select: none;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.color-input {
    width: 80px;
    height: 50px;
    cursor: pointer;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transition: background 0.5s ease;
}

/* 자동화 파트 버튼 스타일 (파트 선택 모달) */
#selectPart2 {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffa500 100%);
}

#selectPart2:hover {
    background: linear-gradient(135deg, #ff5252 0%, #ff8c00 100%);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.event-list {
    max-height: 400px;
    overflow-y: auto;
}

.event-item {
    padding: 15px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.event-item:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.event-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.event-item-title {
    font-weight: 600;
    font-size: 16px;
    color: #212529;
}

.event-item-time {
    font-size: 12px;
    color: #6c757d;
}

.event-item-description {
    font-size: 14px;
    color: #495057;
    margin-top: 5px;
}

.event-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.event-item-actions button {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.event-item-actions .btn-edit {
    background: #667eea;
    color: white;
}

.event-item-actions .btn-edit:hover {
    background: #5568d3;
}

.event-item-actions .btn-delete {
    background: #dc3545;
    color: white;
}

.event-item-actions .btn-delete:hover {
    background: #c82333;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@media (max-width: 1400px) {
    .calendar-layout {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .calendar-wrapper {
        margin: 0;
        width: 100%;
        max-width: 900px;
    }
    .side-panel {
        position: static;
        transform: none;
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
        text-align: center;
    }
    .legend-panel {
        width: 100%;
    }
    .color-legend {
        flex-direction: row;
        gap: 20px;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 900px) {
    .calendar-header h1 {
        font-size: 22px;
    }
    .calendar-wrapper {
        width: 100%;
        max-width: 100%;
    }
    .legend-item {
        justify-content: center;
    }
    
    .day {
        padding: 10px 5px;
        font-size: 14px;
        min-height: 100px;
    }
    
    .day-number {
        font-size: 14px;
    }
    
    .event-item-preview {
        font-size: 10px;
        padding: 5px 6px;
    }
    
    .event-item-preview .event-time {
        font-size: 8px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
}

/* [변경-추가] 우측 범례가 잘리지 않도록 오버플로우 해제 */
.calendar-wrapper { /* [변경] */
    overflow: visible; /* [변경] 기존 hidden을 덮어써서 우측 사이드바 표시 */
}
