/* 기본 스타일 */
body { 
    font-family: 'Noto Sans KR', sans-serif; 
    background-color: #f3f4f6; 
    min-height: 100dvh;
}

/* 모바일 안전 영역 보정 */
main {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.card { 
    background-color: white; 
    border-radius: 0.75rem; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
    padding: 1.5rem; 
    border: 1px solid #e5e7eb; 
}

/* 탭 버튼 */
.tab-btn { 
    padding: 12px 20px; 
    font-weight: 600; 
    color: #6b7280; 
    border-bottom: 3px solid transparent; 
    transition: all 0.2s; 
    white-space: nowrap; 
}
.tab-btn:hover { color: #374151; }
.tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; }

/* 테이블 */
.base-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 0.9rem; 
    text-align: center; 
}
.base-table th { 
    background-color: #f9fafb; 
    border: 1px solid #e5e7eb; 
    padding: 8px; 
    font-weight: 700; 
    color: #374151; 
}
.base-table td { 
    border: 1px solid #e5e7eb; 
    padding: 6px; 
    height: 50px; 
    min-height: 50px;
    vertical-align: middle; 
}

/* 그리드 입력 */
.grid-input { 
    width: 100%; 
    height: 100%; 
    text-align: center; 
    border: none; 
    outline: none; 
    background: transparent; 
    font-size: 0.9rem; 
    cursor: cell; 
}
.grid-input.locked {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}
.grid-input:focus { 
    background-color: #e0e7ff; 
    font-weight: bold; 
    box-shadow: inset 0 0 0 2px #6366f1; 
}
.grid-input.dragging { opacity: 0.5; }
.grid-input.drag-over { 
    background-color: #fef3c7; 
    box-shadow: inset 0 0 0 2px #f59e0b; 
}
.grid-input.copied { animation: copyFlash 0.3s ease; }
@keyframes copyFlash { 
    0%, 100% { background: transparent; } 
    50% { background: #86efac; } 
}

/* 커스텀 모달 */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.5); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 9999; 
    backdrop-filter: blur(2px); 
}
.modal-box { 
    background: white; 
    border-radius: 16px; 
    padding: 24px 32px; 
    max-width: 400px; 
    width: 90%; 
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); 
    animation: modalIn 0.2s ease-out; 
}
@keyframes modalIn { 
    from { opacity: 0; transform: scale(0.9) translateY(-20px); } 
    to { opacity: 1; transform: scale(1) translateY(0); } 
}
.modal-title { 
    font-size: 1.1rem; 
    font-weight: 700; 
    color: #1f2937; 
    margin-bottom: 12px; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}
.modal-message { 
    color: #4b5563; 
    line-height: 1.6; 
    margin-bottom: 20px; 
}
.modal-btn { 
    padding: 10px 24px; 
    border-radius: 8px; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.15s; 
}
.modal-btn-primary { 
    background: linear-gradient(135deg, #6366f1, #4f46e5); 
    color: white; 
    border: none; 
}
.modal-btn-primary:hover { 
    transform: translateY(-1px); 
    box-shadow: 0 4px 12px rgba(99,102,241,0.4); 
}
.modal-btn-danger { 
    background: linear-gradient(135deg, #ef4444, #dc2626); 
    color: white; 
    border: none; 
}
.modal-btn-danger:hover { 
    transform: translateY(-1px); 
    box-shadow: 0 4px 12px rgba(239,68,68,0.4); 
}
.modal-btn-cancel { 
    background: #f3f4f6; 
    color: #4b5563; 
    border: 1px solid #e5e7eb; 
}
.modal-btn-cancel:hover { background: #e5e7eb; }

/* 과목 칩 */
.subject-chip { 
    display: inline-flex; 
    align-items: center; 
    padding: 2px 8px; 
    border-radius: 12px; 
    font-size: 0.8rem; 
    margin: 2px; 
    cursor: default; 
    border: 1px solid #e0e7ff; 
    background: #eef2ff; 
    color: #4338ca; 
}
.subject-chip .del-btn { 
    margin-left: 6px; 
    cursor: pointer; 
    color: #818cf8; 
}
.subject-chip .del-btn:hover { color: #ef4444; }

/* 시간표 셀 */
.tt-cell { 
    height: 55px; 
    min-height: 55px; 
    max-height: 55px;
    cursor: pointer; 
    font-size: 0.85rem; 
    vertical-align: middle; 
    transition: background 0.1s;
    padding: 8px 4px;
}
.tt-cell:hover { background-color: #f3f4f6; }
.cell-fixed { 
    background-color: #eff6ff; 
    color: #1e40af; 
    font-weight: 600; 
    pointer-events: none; 
}
.cell-jeondam { 
    background-color: #fdf2f8; 
    color: #be185d; 
    font-weight: 600; 
}
.cell-damim { 
    background-color: #ffffff; 
    color: #374151; 
}
.cell-disabled { 
    background-color: #e5e7eb; 
    color: #9ca3af; 
    pointer-events: none; 
    background-image: linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 50%, #f3f4f6 50%, #f3f4f6 75%, transparent 75%, transparent); 
    background-size: 10px 10px; 
}
.cell-locked {
    background-color: #f3f4f6;
    color: #9ca3af;
    pointer-events: none;
}

/* 교사 카드 */
.teacher-card { 
    border: 2px solid #374151; 
    border-radius: 4px; 
    overflow: hidden; 
    background: white; 
    margin-bottom: 20px; 
}
.teacher-header { 
    padding: 10px; 
    border-bottom: 1px solid #e5e7eb; 
    background: #f9fafb; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
.teacher-grid th { 
    background: #f3f4f6; 
    border: 1px solid #d1d5db; 
    padding: 6px; 
    font-size: 0.85rem; 
}
.teacher-grid td { 
    border: 1px solid #d1d5db; 
    height: 40px; 
    text-align: center; 
    font-size: 0.9rem; 
    font-weight: 500; 
}

/* 입력 필드 */
.edit-input { 
    width: 100%; 
    text-align: center; 
    border: 1px solid transparent; 
    border-radius: 4px; 
    padding: 2px; 
}
.edit-input:hover { border-color: #d1d5db; }
.edit-input:focus { 
    border-color: #4f46e5; 
    background: #eef2ff; 
    outline: none; 
}

/* 팔레트 아이템 */
.palette-item { 
    padding: 8px 12px; 
    border-radius: 8px; 
    border: 1px solid #e5e7eb; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 6px; 
    transition: all 0.2s; 
}
.palette-item:hover { background-color: #f3f4f6; }
.palette-item.active { 
    background-color: #e0e7ff; 
    border-color: #6366f1; 
    color: #4338ca; 
}

/* 카운트 뱃지 */
.count-badge { 
    font-size: 0.75rem; 
    padding: 2px 6px; 
    border-radius: 4px; 
    background: #e5e7eb; 
    min-width: 40px; 
    text-align: center; 
}
.count-badge.done { 
    background: #dcfce7; 
    color: #166534; 
}

/* 동기화 표시 */
#sync-indicator { transition: all 0.3s; }

/* 학급 시간표 그리드 */
#editor-grid-body tr {
    height: 55px !important;
}
#editor-grid-body td {
    height: 55px !important;
    min-height: 55px !important;
    max-height: 55px !important;
}

/* 교사 시간표 */
.teacher-cell { 
    height: 36px; 
    min-height: 36px;
    cursor: pointer;
    transition: background 0.1s;
}
.teacher-cell:hover { background-color: #e0e7ff; }
.teacher-cell.selected { background-color: #c7d2fe; }

