/* 폰트 설정 */
* {
    font-family: 'Noto Sans KR', sans-serif;
}

/* 탭 버튼 스타일 */
.tab-button {
    position: relative;
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: #6b7280;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-button:hover {
    color: #3b82f6;
    background-color: #f3f4f6;
}

.tab-button.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background-color: #eff6ff;
}

.tab-icon {
    font-size: 1.25rem;
}

/* 탭 컨텐츠 */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 캘린더 스타일 */
.calendar-container {
    /* overflow-x: auto; 제거 - sticky가 작동하도록 */
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

#calendar,
#shortage-calendar {
    min-width: 1200px;
    width: 100%;
}

.calendar-table {
    width: 100%;
    min-width: 950px;
    border-collapse: collapse;
    background-color: #f0fdf4; /* 연한 녹색 배경 */
}

.calendar-table th,
.calendar-table td {
    border: 1px solid #d1d5db;
    padding: 0.25rem;
    text-align: center;
    font-size: 0.7rem;
    min-width: 24px;
    max-width: 24px;
    width: 24px;
    height: 32px;
}

/* 요일/날짜 라벨 행 스타일 */
.day-of-week-row {
    height: 18px !important;
    max-height: 18px !important;
}

.day-of-week-row td {
    height: 18px !important;
    max-height: 18px !important;
    line-height: 18px !important;
    padding: 0px 2px !important;
}

.day-label {
    font-size: 8px !important;
    padding: 0px 2px !important;
    background-color: #e5e7eb;
    text-align: center;
    height: 18px !important;
    max-height: 18px !important;
    line-height: 18px !important;
    vertical-align: middle;
}

.calendar-table th {
    background-color: #e0e7ff;
    font-weight: 600;
    color: #1e40af;
    position: sticky;
    top: 0;
    z-index: 10;
}

.calendar-table .month-label {
    background-color: #dbeafe;
    font-weight: 600;
    color: #1e3a8a;
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    position: sticky;
    left: 0;
    z-index: 5;
}

.calendar-table .month-label[rowspan="2"] {
    vertical-align: middle;
}

.calendar-table .month-total {
    background-color: #dbeafe;
    font-weight: 600;
    color: #1e3a8a;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    position: sticky;
    right: 0;
    z-index: 5;
}

.calendar-table .month-total[rowspan="2"] {
    vertical-align: middle;
}

/* 날짜 셀 스타일 */
.date-cell {
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    position: relative;
}

.date-cell.calendar-disabled {
    cursor: not-allowed;
    opacity: 0.4;
    pointer-events: none;
}

.date-cell:hover {
    background-color: #fef9c3 !important;
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
}

.date-cell.calendar-disabled:hover {
    transform: none;
    box-shadow: none;
}

.date-cell.disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.5;
}

.date-cell.weekend {
    background-color: #dbeafe; /* 연한 푸른색 */
}

.date-cell.holiday {
    background-color: #bfdbfe; /* 푸른색으로 통일 */
}

.date-cell.annual {
    background-color: #fde047; /* 더 진한 노란색 */
    font-weight: 600;
}

.date-cell.compensatory {
    background-color: #fb923c; /* 더 진한 오렌지 */
    font-weight: 600;
}

.date-cell.check {
    background-color: #67e8f9; /* 밝은 CYAN */
    font-weight: 600;
}

/* 연차가 겹쳤을 때 */
.date-cell.annual.weekend,
.date-cell.annual.holiday {
    background: linear-gradient(135deg, #fef08a 0%, #fef08a 50%, #bfdbfe 50%, #bfdbfe 100%);
}

.date-cell.compensatory.weekend,
.date-cell.compensatory.holiday {
    background: linear-gradient(135deg, #fed7aa 0%, #fed7aa 50%, #bfdbfe 50%, #bfdbfe 100%);
}

/* 잔여 음수 스타일 */
#remaining.negative,
#compensatory-remaining.negative {
    color: #dc2626;
    font-weight: 700;
    background-color: #fee2e2 !important;
    border-color: #dc2626 !important;
}

/* 근무인원부족 위험도 표시 */
.date-cell.danger-1 {
    background-color: #fee2e2 !important; /* 가장 옅은 빨강 - 차이 1 */
}

.date-cell.danger-2 {
    background-color: #fecaca !important; /* 중간 빨강 - 차이 2-3 */
}

.date-cell.danger-3 {
    background-color: #fca5a5 !important; /* 진한 빨강 - 차이 4-5 */
}

.date-cell.danger-4 {
    background-color: #f87171 !important; /* 가장 진한 빨강 - 차이 6+ */
}

.date-cell.danger-text {
    color: #991b1b !important;
    font-weight: 700 !important;
    font-size: 0.7rem !important;
}

/* 드래그 선택 스타일 */
.date-cell.drag-selected {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    background-color: #dbeafe !important;
    z-index: 10;
}

/* 근무가능 입력 필드 활성화 (초록색) */
.input-active {
    background-color: #d1fae5 !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* 셀 우하단 커스텀 값 표시 */
.cell-custom-value {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 8px;
    color: #6b7280;
    font-weight: 600;
    pointer-events: none;
}

/* ===== [신청] 탭 스타일 ===== */

/* 좌측 패널 스타일 */
#apply-left-panel {
    border-right: 2px solid #e5e7eb;
    background-color: #fafafa;
}

/* 구성원 카드 */
.employee-card {
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
}

.employee-card:hover {
    background: #f0f9ff;
    border-color: #3b82f6;
    transform: translateX(2px);
}

.employee-card.selected {
    background: #dbeafe;
    border-color: #2563eb;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.employee-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 6px;
}

.employee-stats {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: #6b7280;
}

.employee-stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 9px;
    color: #9ca3af;
    margin-bottom: 2px;
}

.stat-value {
    font-weight: 600;
    color: #374151;
}

/* Canvas 컨테이너 */
#apply-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 줌 컨트롤 */
#zoom-in, #zoom-out, #zoom-reset {
    min-width: 36px;
    transition: all 0.2s;
}

#zoom-in:active, #zoom-out:active {
    transform: scale(0.95);
}

/* ===== [신청] 탭 전용 스타일 ===== */

/* body 전체 스크롤 방지 */
body, html {
    overflow-x: hidden;
}

/* 캘린더 컨테이너 - 스크롤 영역 */
#apply2-calendar {
    overflow-x: auto;  /* 가로 스크롤 활성화 */
    overflow-y: auto;  /* 세로 스크롤 활성화 */
    max-height: calc(100vh - 250px);
    position: relative;
    width: 100%;
    max-width: 100%;  /* 부모 너비 제한 */
}

/* 캘린더 테이블 */
.calendar-table {
    border-collapse: collapse;
    /* 가로 스크롤을 위해 고정 너비 설정 */
    width: max-content;  /* 내용 너비에 맞춤 */
    min-width: 100%;  /* 최소 100% */
    table-layout: fixed;  /* 고정 레이아웃으로 셀 크기 유지 */
}

/* 상단 헤더 (월 + 날짜) - 세로 스크롤 시 고정 */
.calendar-table thead {
    position: sticky;
    top: 0;
    z-index: 10;  /* 헤더 레이어 */
    background-color: #e0e7ff;
}

/* thead 행 높이 명시 */
.calendar-table .month-header-row {
    height: 40px;
}

.calendar-table .date-number-row {
    height: 30px;
}

/* 헤더 내 이름 셀 - 교차 코너 (최상위) */
.calendar-table .name-header-cell {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 20;  /* 최상위 */
    background-color: #e0e7ff;
    font-weight: 700;
    padding: 8px;
    border: 2px solid #93c5fd;
    min-width: 100px;
    width: 100px;
}

/* 월 헤더 */
.calendar-table .month-header {
    background-color: #dbeafe;
    color: #1e3a8a;
    font-weight: 700;
    padding: 8px 4px;
    border: 1px solid #93c5fd;
    text-align: center;
}

/* 날짜 번호 */
.calendar-table .date-number {
    background-color: #e0e7ff;
    font-size: 10px;
    padding: 6px 4px;
    text-align: center;
    border: 1px solid #c7d2fe;
    min-width: 40px;
    max-width: 40px;
    width: 40px;
}

/* 직원 이름 셀 - 가로 스크롤 시 고정 */
.calendar-table .employee-name-cell {
    position: sticky;
    left: 0;
    top: 70px;  /* ⭐ thead 높이(40+30) */
    z-index: 5;  /* 이름 열 레이어 */
    background-color: #f0fdf4;
    font-weight: 600;
    padding: 4px 8px;
    text-align: center;
    vertical-align: middle;
    border-right: 2px solid #86efac;
    border-bottom: 1px solid #d1fae5;
    min-width: 100px;
    width: 100px;
}

/* 요일 행 */
.calendar-table .day-of-week-row {
    height: 18px;
}

.calendar-table .day-of-week-row .day-label {
    font-size: 10px;
    text-align: center;
    padding: 4px;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    min-width: 40px;
    max-width: 40px;
    width: 40px;
    height: 20px;
}

/* 날짜 행 */
.calendar-table .date-row {
    height: 32px;
}

.calendar-table .date-cell {
    min-width: 40px;
    max-width: 40px;
    width: 40px;
    height: 40px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #d1d5db;
    padding: 4px;
}

.calendar-table .date-cell:hover {
    /* transform: scale(1.1); 제거 - sticky 보호 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    z-index: 5;
}

.calendar-table .date-cell.calendar-disabled {
    cursor: not-allowed;
    opacity: 0.5;
}


/* 입력 필드 포커스 효과 */
input:focus,
select:focus {
    outline: none;
}

/* 로딩 스피너 */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 상태 메시지 */
.status-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.status-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.status-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* 로그 항목 */
.log-item {
    padding: 0.75rem;
    background-color: #f9fafb;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.log-item:hover {
    background-color: #f3f4f6;
}

/* 반응형 */
@media (max-width: 1024px) {
    .flex.gap-8 {
        flex-direction: column;
    }
    
    .w-64 {
        width: 100%;
    }
}

/* 스크롤바 스타일 */
.calendar-container::-webkit-scrollbar {
    height: 8px;
}

.calendar-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.calendar-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.calendar-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 툴팁 효과 */
.date-cell[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 0.25rem;
}
